Skip to content

Instantly share code, notes, and snippets.

@carlinmack
Last active July 3, 2019 14:34
Show Gist options
  • Save carlinmack/94dc20afb3729c40fbac06efc93466fa to your computer and use it in GitHub Desktop.
Save carlinmack/94dc20afb3729c40fbac06efc93466fa to your computer and use it in GitHub Desktop.
Perl Arrays and Hashes
Creation Reference Dereference
Array @array = () $ref = []
@array = ('one', two) $value = $array[$index];
$ref = ['one', 'two'] $value = $ref->[$index];
@array[0] = 'one' $ref->[0] = 'one'
$ref = \@foo @new_array = @{$ref}
Hash %hash = () $ref = {}
%hash = (key => 'value') $value = $hash{key}
$ref = {key => 'value'} $value = $ref->{key}
$hash{key} = 'value' $ref->{key} = "value"
$ref = \%hash %new_hash = %{$ref}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment