The example I showed with $href->%* was highly simplistic. It was intended to show that, with 5.28, I could use the new syntax and didn't need to include a 'use feature' statement.

When dealing with simple references, I would typically use @$aref, %$href, and so on, rather than $aref->@*, $href->%*, etc.

When working with complex data structures, that simple reference becomes a series of keys and indexes read from left-to-right. Adding a postfix dereference continues that left-to-right progression: you don't need to scan back to the beginning of the expression to determine what dereferencing is being used. Consider these two:

$href->{$key1}[$i]{$key2}->%*; %{$href->{$key1}[$i]{$key2}};

Of course, they're only short, example variable names. In production code, I'd be using meaningful variable names:

$meaningful_href->{$meaningful_outer_key}[$meaningful_index]{$meaningf +ul_inner_key}->%*; %{$meaningful_href->{$meaningful_outer_key}[$meaningful_index]{$meanin +gful_inner_key}};

Here, the benefit of not having to scan back to the beginning of the expression becomes more obvious.

Except for the simple references, like %$href, there's only one additional character when using the postfix syntax: I wouldn't consider that to be a reason to use, or not use, it.

When whatever is being dereferenced is more complicated than a simple reference, I would recommend adding the braces (e.g. prefer @{$complex_ref} over @$complex_ref). Even when @$complex_ref seems completely transparent to the author, it might easily be less obvious to the next maintainer.

Using postfix dereferencing, in the contexts I've described above, is my personal preference for the reasons given. I would recommend its use to others for the same reasons. I certainly wouldn't suggest anyone must use it.

In "Re^3: nodelocked vs floating", I did point out that it took me "a little while to get used to": if you're considering giving it a try, you might also want to give it a little while also.

Finally, some practical notes on usage:

— Ken


In reply to Re^7: nodelocked vs floating by kcott
in thread nodelocked vs floating by vkknava

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.