http://www.perlmonks.org?node_id=674427


in reply to Re: blocks and using braces around filehandles with print
in thread blocks and using braces around filehandles with print

(Not my question, but thought I'd jump in:)

So the rules here are the same as whether or not you need curlies for dereferencing an array (etc.)? e.g. @$arrayref but @{ $arrayrefs[0] } ?


I'm a peripheral visionary... I can see into the future, but just way off to the side.

Replies are listed 'Best First'.
Re^3: blocks and using braces around filehandles with print
by ikegami (Patriarch) on Mar 16, 2008 at 05:27 UTC
    There really isn't any connection between those two kinds of curlies. Those of which you speak act like parens to modify precedence and are solely used in dereferencing.
    $$array[0] # Short for ${ $array }[0] ${ $array }[0] # The first element of the array referenced by $array ${ $array[0] } # The scalar referenced by the first element of @array

    A third, similar type of curlies is used in interpolation to show where the variable name ends.

    "foo$varbar" # Equivalent to "foo" . $varbar "foo${var}bar" # Equivalent to "foo" . $var . "bar"

      Ah, okay. Thank you :)

      Sorry for the slight hijack!


      I'm a peripheral visionary... I can see into the future, but just way off to the side.