[tpm] dereferencing anonymous hashes

Shaun Fryer sfryer at sourcery.ca
Tue Apr 10 13:23:27 PDT 2007


On Tue, Apr 10, 2007 at 02:58:33PM -0400, Fulko Hew wrote:
> It makes me wonder then... whats the subtle difference
> between
> $x = () and $x = {} when dealing with hashes and their references?

@x = (); # this is an array
%x = (); # this is an array, in hash context
$x = \@x; # this is a reference to an array
$x = \%x; # this is a reference to a hash
$x = []; # this is a reference to an array
$x = {}; # this is a reference to a hash

So one might do this...

@x = qw( three element array );
$x = \@x;

...or...

$x = [ qw( three element array ) ]; # same thing

--
    Shaun Fryer
    tf: 866-920-9209


More information about the toronto-pm mailing list