Or perhaps you mean that you want to compare the first field of the first line in the file against the first fields of all subsequent lines? In that case, perhaps something like (also untested):
(Of course, you have to write the compare() function!)... open file handles, etc. ... defined(my $first_line = <RAW>) or die "reading raw input: $!"; chomp $first_line; my ($first_line_first_field) = split m{ , \s* }xms, $first_line; while (defined(my $following_line = <RAW>)) { chomp $following_line; my ($following_line_first_field) = split m{ , \s* }xms, $following +_line; compare($first_line_first_field, $following_line_first_field); } close RAW or die "closing raw handle: $!";
Update: Added error check to original
my $first_line = <RAW>;
statement above to make it
defined(my $first_line = <RAW>) or die "reading raw input: $!";
Give a man a fish: <%-{-{-{-<
In reply to Re^5: How do I select first string of a two dimensional array to compare to other values?
by AnomalousMonk
in thread How do I select first string of a two dimensional array to compare to other values?
by joi1369
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |