G'day perldigious,

This is to address a number of points in this branch of the thread; in particular, versions, features, warnings and interpolating postfix dereferencing within strings.

Firstly, starting with v5.24:

$ perl -v | head -2 | tail -1 This is perl 5, version 24, subversion 0 (v5.24.0) built for darwin-th +read-multi-2level

This code recognises postderef syntax outside of strings but not within strings:

#!/usr/bin/env perl -l use strict; use warnings; my $x = [qw{test string}]; print $x->@*; print "$x->@*";

Output:

teststring ARRAY(0x7fc63c005498)->@*

Adding either of these:

use 5.024;

or

use feature qw{postderef_qq};

Allows interpolation within strings:

Output:

teststring test string

Now looking at v5.20.

$ perl -v | head -2 | tail -1 This is perl 5, version 20, subversion 0 (v5.20.0) built for darwin-th +read-multi-2level

Output using the same initial code as before:

Array found where operator expected at ./pm_1174734_postderef.pl line +11, at end of line (Missing operator before ?) syntax error at ./pm_1174734_postderef.pl line 11, near "->@*" Execution of ./pm_1174734_postderef.pl aborted due to compilation erro +rs.

To make this work, you need to turn off the experimental warnings (after the use warnings line) and use both the postderef and the postderef_qq features.

use warnings; no warnings qw{experimental::postderef}; use feature qw{postderef postderef_qq};

Using the code and version shown, this outputs:

teststring test string

Specifying a minimum version in the code, but running with a lesser version, gives:

Perl v5.20.0 required--this is only v5.18.0, stopped at ... BEGIN failed--compilation aborted at ...

This tells you how to fix but not why.

Not specifying the version, gives:

Unknown warnings category 'experimental::postderef' at ... BEGIN failed--compilation aborted at ...

This provides the why but not the how (i.e. you'll need some research to determine if that's a valid category and, if so, at what version it was introduced).

I prefer to specify the version. You may have a different preference or, perhaps, might be guided by in-house coding standards.

See also:

Updates:

— Ken


In reply to Re^3: Syntax Question Related to "join" on a Complex Data Structure [postderef and postderef_qq] by kcott
in thread Syntax Question Related to "join" on a Complex Data Structure by perldigious

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.