Apart from that, I wonder if your "readmap" command ever outputs any lines with initial whitespace. If so, your split statement should be:use strict; use warnings;
because that will differ from /\s+/ -- try this snippet to see the difference:@fields = spit " ";
update: To clarify the issue, using "\s+" for splitting will get you into real trouble if the "readmap" output varies in terms of presence/absence of whitespace at the beginning of each line. If the output is consistent in this regard, then using "\s+" is probably not a problem -- you just need to make sure you've counted the field indexes correctly, so that $fields[2] etc really point at what you want them to point at.$_ = " begins with whitespace"; @a = split " "; @b = split /\s+/; print "quoted-space split returns ", scalar @a, " elements\n"; print "\\s+ split returns ", scalar @b, ", first one has length ",leng +th($b[0]),"\n";
In reply to Re: Working out frequency statistics with perl
by graff
in thread Working out frequency statistics with perl
by wishartz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |