G
Guy
Is this correct? The type of parenthesis etc?
Guy
@x; Entire Array
%x; Entire Hash
$x[0]; One item of Array
%x{key}; One item of Hash
$r=\@x; Referencing Array variable
$r=\%x; Referencing Hash variable
@$r; De-referecing entire array
De-referecing entire hash ???
$$r[0]; Referencing one array item
$$r{key}; Referencing one hash item
(v1,v2); Anonymous Array (depending on context)
(k1,v1,k2,v2); Anonymous Hash (depending on context)
[v1,v2]; Reference to Anonymous Array
{k1,v1,k2,v2}; Reference to Anonymous Hash
$a=(1,2,3)[0]; Slice of a list
@x=(1,2,3)[0,1]; Slices of a list
($a,$b)=(1,2,3)[0,1]; Slices of a list
@y=@x[0,1]; Slices of array
@x=@y{k1,k2}; Slices of hash (use @ not % because partial hash)
@x=@y{@keys}; Slices of hash (use @ not % because partial hash)
@x{@keys}=@values; Assigning to specific or all keys of hash
$y[0]=\@x; Creating Array of Array (2D Array)
$y[0][0]; Accessing item
$y[0]=\%x; Creating Array of Hash
$y[0]{key}; Accessing item
$y{key}=%x; Creating Hash of Hash
$y{key}{key2}; Accessing item
Guy
@x; Entire Array
%x; Entire Hash
$x[0]; One item of Array
%x{key}; One item of Hash
$r=\@x; Referencing Array variable
$r=\%x; Referencing Hash variable
@$r; De-referecing entire array
De-referecing entire hash ???
$$r[0]; Referencing one array item
$$r{key}; Referencing one hash item
(v1,v2); Anonymous Array (depending on context)
(k1,v1,k2,v2); Anonymous Hash (depending on context)
[v1,v2]; Reference to Anonymous Array
{k1,v1,k2,v2}; Reference to Anonymous Hash
$a=(1,2,3)[0]; Slice of a list
@x=(1,2,3)[0,1]; Slices of a list
($a,$b)=(1,2,3)[0,1]; Slices of a list
@y=@x[0,1]; Slices of array
@x=@y{k1,k2}; Slices of hash (use @ not % because partial hash)
@x=@y{@keys}; Slices of hash (use @ not % because partial hash)
@x{@keys}=@values; Assigning to specific or all keys of hash
$y[0]=\@x; Creating Array of Array (2D Array)
$y[0][0]; Accessing item
$y[0]=\%x; Creating Array of Hash
$y[0]{key}; Accessing item
$y{key}=%x; Creating Hash of Hash
$y{key}{key2}; Accessing item