> ... but B::Deparse seems to know what's going on: ...

B::Deparse can't help here, cause it's a runtime error and not a syntax problem.

> ... I suspect the ; after $res is the key ...

The ';' you are seeing is an indicator that %{ } and alike are effectively do { } blocks plus dereferencing.

lanx@nc10-ubuntu:~$ perl -e '$r={a=>1};print %{$r;},"\n"' a1 lanx@nc10-ubuntu:~$ perl -MO=Deparse,p -e '$r={a=>1};print %{$r;},"\n" +' $r = {'a', 1}; print %{$r;}, "\n"; -e syntax OK lanx@nc10-ubuntu:~$ perl -MO=Deparse,p -e 'print %{ $r={a=>1};$r; },"\ +n"' print %{$r = {'a', 1}; $r;}, "\n"; -e syntax OK lanx@nc10-ubuntu:~$ perl -e 'print %{ $r={a=>1};$r; },"\n"' a1

Interesting, well spotted! =)

UDPATE

Reminds me of this old trick to have code executed within interpolation

DB<100> print " @{ [ 1..10 ] } " 1 2 3 4 5 6 7 8 9 10

maybe clearer

DB<106> print " @{ $a++; [1..$a ] } " 1 DB<107> print " @{ $a++; [1..$a ] } " 1 2 DB<108> print " @{ $a++; [1..$a ] } " 1 2 3

Cheers Rolf

( addicted to the Perl Programming Language)


In reply to Re^4: Referring to an array without copying to a separate variable first by LanX
in thread Referring to an array without copying to a separate variable first by willjones

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.