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.
Yes. From Perl 5.8.8 perldoc:
In scalar context, returns the number of fields found and splits into the @_ array. Use of split in scalar context is deprecated, however, because it clobbers your subroutine arguments.
AFAICT, it was deprecated in Perl 5.8 and removed in 5.12. Unfortunately, I could not find a reference to it in any perldelta. Indeed, bug report #97382 complains that it was removed from Perl 5.12 without appearing in perldelta.

As a simpler standalone test of this specific deprecation, I ran this program (dent.pl):

use strict; use warnings; use Data::Dumper; my %hash = map { split; $_[1] => $_[0] } "value key", "meaning-of-life + 42"; print Dumper( \%hash );
with Perl 5.8.8 and it produced:
Use of implicit split to @_ is deprecated at dent.pl line 4. $VAR1 = { '42' => 'meaning-of-life', 'key' => 'value' };
That is, it worked while printing a warning to stderr (note that you need use warnings to see the warning). As you might expect, running it with Perl 5.12+ fails spectactularly, producing:
Useless use of split in void context at dent.pl line 4. Use of uninitialized value in list assignment at dent.pl line 4. Use of uninitialized value in list assignment at dent.pl line 4. $VAR1 = { '' => undef };

This version seems to work everywhere:

use strict; use warnings; use Data::Dumper; my %hash = map { (split)[1,0] } "value key", "meaning-of-life 42"; print Dumper( \%hash );

Apart from the pragmatic "writing to @_ clobbers your subroutine arguments" reason, another (more theoretical) reason for changing this behavior is that a function that sets a global variable (i.e. @_) is a function with a side-effect and side effects are considered evil in functional programming because they violate referential transparency.

BTW, I am much more intimate with this specific Perl deprecation that I ever wanted to be owing to this grueling golf game (see "Fun with split" section). Note that side-effects, while anathema to functional purists, are cherished by golfers because they often lead to shorter code ... as they did in this golf game.


In reply to Re^2: newer Perl version rejects this by eyepopslikeamosquito
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.