Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I'm not sure if this is a bug or not. I'm running perl 5, version 26, subversion 1 (v5.26.1) built for MSWin32-x64-multi-thread from Strawberry Perl. If I have a %hash, I can pass it to a function with \%hash. In the function, I can assign elements by autovivification:
$$hash{'key1'}{"$var2"} = $value;
or
$$hash->{'key1'}->{"$var2"} = $value;
BUT, and this is the real issue, if I want to print all the 'var2's, I must do something (still in the function) like:
foreach $key (keys %$hash{'key1'}->%* ){ print "$key\n"; }
Omitting the ->%* produces an error "Experimental keys on scalar is now forbidden" and if I omit the leading % it says the global symbol $hash is not defined. Perl version 5.24 is when the ->%* was supposed to be a nearly 1:1 compatible replacement for %$ dereferencing (and no longer experimental), and as far as I know there's probably not supposed to be a circumstance where you need BOTH. After further testing, with the $${}{} assignment I can get the keys inside the function using %{ $$hash{'key'} } or $$hash{'key'}->%* . Is there an explanation for the referencing/syntax going on?

In reply to 5.26 sigil reference syntax in subfunction by chenhonkhonk

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (4)
    As of 2019-09-18 00:45 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      The room is dark, and your next move is ...












      Results (219 votes). Check out past polls.

      Notices?