in reply to Re^2: csv to hash table
in thread csv to hash table
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: csv to hash table
by GrandFather (Saint) on Nov 19, 2013 at 20:18 UTC | |
by kcott (Archbishop) on Nov 20, 2013 at 06:18 UTC |