I was reading the docs for splice recently and came across this:

Starting with Perl 5.14, splice can take a scalar EXPR, which must hold a reference to an unblessed array. The argument will be dereferenced automatically. This aspect of splice is considered highly experimental. The exact behaviour may change in a future version of Perl.

To avoid confusing would-be users of your code who are running earlier versions of Perl with mysterious syntax errors, put this sort of thing at the top of your file to signal that your code will work only on Perls of a recent vintage:

use 5.014; # so push/pop/etc work on scalars (experimental)

I have to ask, is it really worth breaking backwards compatibility, that is, forcing an upgrade to a newer version of Perl, by adding this "feature"? I have never had a problem using @{$foo} when using splice (or push or pop or anything else expecting an array or list) on an array reference. Yes, the old syntax still works just fine, but if I want to use a module that has the newer syntax I now have to load a newer version of Perl.

I doubt that I will ever use this new syntax unless I am convinced that 99% of the Perl universe will support it. Simply put, if it ain't broke, don't ..., errr, fix it.

Disclaimer: until quite recently I had to work with Perl 5.8.8 the vast majority of the time and only rarely saw 5.10. Consequently I write code to run on 5.8.8 and hope that new modules will load on it. (If you ever need an excuse for a long lunch break install Dist::Zilla on 5.8.8.)


In reply to Is auto-dereferencing worth forcing upgrades to newer versions of Perl? by boftx

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.