in reply to newer Perl version rejects this
In older versions of Perl, in scalar context split would split into @_, and return the number of elements resulting from the split operation. This "feature" was deprecated at least as long ago as 5.8.8, but possibly earlier. And it has since been removed from Perl. I don't know which version of Perl removed it, but clearly it's not present in 5.20.1.
You have another bug as well. The while loop's first iteration will read the first line of your input file, but you never use it. The "map" line will slurp the remainder of the file, so there should never be a second iteration of the while loop. If the first line of your file is a header line, that's probably ok. But if the first line is real data, you're losing it.
You can fix the v5.20 issue by changing the map line to this:
my %hash = map{ chomp; local @_ = split/ /; $_[1] => $_[0]; } <$fh>;
Or to this:
my %hash = map { chomp; (split / /)[1,0]; } <$fh>;
Removing the while loop should clear up the other bug. If you still need to skip past a header line, do it more explicitly.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: newer Perl version rejects this
by eyepopslikeamosquito (Archbishop) on Feb 08, 2015 at 10:45 UTC | |
|
Re^2: newer Perl version rejects this
by gabocze (Initiate) on Sep 17, 2016 at 22:03 UTC | |
by davido (Cardinal) on Sep 18, 2016 at 05:17 UTC | |
|
Re^2: newer Perl version rejects this
by ggadd (Acolyte) on Feb 08, 2015 at 14:13 UTC |