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:
-
change of meaning:
s{expected to be a dead link}{will refer to a different delta}
-
additional doco:
Added manpage names to links: perldelta & perl52400delta
|