Data Structures Quick Reference


This table may be helpful for seeing the syntax used for the common data structures.



Thing
Sigil
Brackets
Example
Accessing
Reference
Deref
Accessing thru ref
Anonymous
Scalar
$
none
$scalar
$scalar
$sref = \$scalar
$scalar = ${$sref} or $scalar = $$sref


Array
@
[]
@array
$array[0]
$aref = \@array
@array = @{$aref} or @array = @$aref
$aref->[0]
$aref=[1,2,'y']
Hash
%
{}
%hash
$hash{'key'}
$href = \%hash
%hash = %{$href} or %hash = %$href
$href->{'key'}
$href={'foo'=>1,'bar'=>2}