You're confusing the filehandle with the record being read.
Using more code than is really necessary to demonstrate the point:
open my $filehandle, ... while (my $record = <$filehandle>) { chomp $record; # Remove the newline # Do stuff with the record text, e.g. my @fields = split /$field_separator/ => $record; ... }
That would normally be coded more succinctly as:
open my $filehandle, ... while (<$filehandle>) { chomp; # Remove the newline # Do stuff with the record text, e.g. my @fields = split /$field_separator/; ... }
In the second code fragment, all instances of $record (from the first fragment) are now $_, which (being the default for chomp, split, and many other functions) can be omitted.
And, just in case it wasn't obvious, that was for general enlightenment, not a recommendation to attempt your own version of Text::CSV. :-)
-- Ken
In reply to Re^3: csv to hash table
by kcott
in thread csv to hash table
by waytoperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |