in reply to Re^4: How do I select first string of a two dimensional array to compare to other values?
in thread How do I select first string of a two dimensional array to compare to other values?

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):

... 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: $!";
(Of course, you have to write the  compare() function!)

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:  <%-{-{-{-<

  • Comment on Re^5: How do I select first string of a two dimensional array to compare to other values?
  • Select or Download Code