in reply to Re: Syntax Question Related to "join" on a Complex Data Structure
in thread Syntax Question Related to "join" on a Complex Data Structure

I do use 5.022 so I have a sufficiently modern version of Perl, though I admit I prefer the old notation choroba used, probably because I'm not very Object Oriented minded (though I admit yours is easier to read at a glance tybalt89). That said, I tried it, and it worked exactly the same, but it gave me the following warning along the way (not sure why).

Array found where operator expected at Web_Chat_IP_Match.pl line 141, +near "->@" (Missing operator before @?)

I've noticed that different people prefer different ways when doing things like this: &{}, %{}, @{}, ${} vs. &$, %$, @$, $$ vs. ->{} and ->[].

I've sensed rumblings of a past holy war, or at least a past split in the clergy that lead to the Perl programmer equivalents of Lutheranism or Protestantism in some of the things I've read about it.

I love it when things get difficult; after all, difficult pays the mortgage. - Dr. Keith Whites
I hate it when things get difficult, so I'll just sell my house and rent cheap instead. - perldigious

Replies are listed 'Best First'.
Re^3: Syntax Question Related to "join" on a Complex Data Structure
by haukex (Archbishop) on Oct 26, 2016 at 13:06 UTC

      That does help, thanks haukex. That use feature 'postderef'; reduced the warning to:

      Postfix dereference is experimental at Web_Chat_IP_Match.pl line 142.

      So "sufficiently modern" really meant "the most recent version" then. :-)

      I'll probably stick to the old block notation anyway, at least for the near foreseeable future. I'm just more comfortable with it I guess.

      I love it when things get difficult; after all, difficult pays the mortgage. - Dr. Keith Whites
      I hate it when things get difficult, so I'll just sell my house and rent cheap instead. - perldigious

        Hi perldigious,

        Oh, right, forgot about that. You can disable the warnings yourself, or there's experimental:

        use feature 'postderef'; no warnings 'experimental::postderef'; # - OR - use experimental 'postderef';

        Regards,
        -- Hauke D

Re^3: Syntax Question Related to "join" on a Complex Data Structure [postderef and postderef_qq]
by kcott (Archbishop) on Oct 27, 2016 at 15:53 UTC

    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

    — Ken