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
In reply to Re: newer Perl version rejects this
by davido
in thread newer Perl version rejects this
by ggadd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |