如果我没有限制,那么在Perl将一条线分为不同的长度,那是很好的办法。 我的数据按栏长度编排,因此第一个变量为1-4级,第二个变量为5-15级等。 每种变量都有不同的长度。
另一种方式是,根据扼杀中的位置,是否有某种方式使用分裂功能,而不是相应的表述?
感谢。
如果我没有限制,那么在Perl将一条线分为不同的长度,那是很好的办法。 我的数据按栏长度编排,因此第一个变量为1-4级,第二个变量为5-15级等。 每种变量都有不同的长度。
另一种方式是,根据扼杀中的位置,是否有某种方式使用分裂功能,而不是相应的表述?
感谢。
是的。 <http://perldoc.perl.org/Functions/un Pack.html>rel=“noretinger”>un Pack
功能与处理固定-width记录非常合适。
my $record = "1234ABCDEFGHIJK";
my @fields = unpack A4A11 , $record; # 1st field is 4 chars long, 2nd is 11
print "@fields"; # Prints 1234 ABCDEFGHIJK
第一个论点是模板,其中标有:unulation/code>,在田地开始和结束时。 第二个论点告诉它,它只是无包装的。
x
。 模板<代码>A4x2A9>可用于忽略上述例子中的<代码>AB>。
http://perldoc.perl.org/Functions/substr.html 方法:
my $first = substr($input, 0, 4);
my $second = substr($input, 5, 10);
# etc...
(如无包装方法一样,但如果你只把几个领域划归一,则在不咨询文件的情况下,子体更容易书写。)
您可使用<代码>()的功能提取数据,但可予以抵消:
$first = substr($line, 0, 4);
$second = substr($line, 4, 11);
另一种选择是定期表达:
($first, $second) = ($line =~ /(.{4})(.{11})/);
I am building a Web interface to monitor an embedded system. I have built a Perl script which runs remote commands and gathers output from that system. Now what I need is a Web interface which makes ...
How do I tell what type of value is in a Perl variable? $x might be a scalar, a ref to an array or a ref to a hash (or maybe other things).
When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a pwd returns still the same directory. Should that be so? I tried this, because in the documentation to chdir I found: "...
I ve read the doc for GetOptions but I can t seem to find what I need... (maybe I am blind) What I want to do is to parse command line like this myperlscript.pl -mode [sth] [inputfile] I can use ...
I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...
I would like to submit a form to a CGI script localy (w3c-markup-validator), but it is too slow using curl and apache, I want to use this CGI script more than 5,000 times in an another script. and ...
So I m running perl 5.10 on a core 2 duo macbook pro compiled with threading support: usethreads=define, useithreads=define. I ve got a simple script to read 4 gzipped files containing aroud 750000 ...
A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...