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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.