Variable | Instantiating the scalar | Instantiating a reference to it | Referencing it | Dereferencing it | Accessing an element |
$scalar | $scalar = "steve"; | $ref = \"steve"; | $ref = \$scalar | $$ref or ${$ref} | N/A |
@list | @list = ("steve", "fred"); | $ref = ["steve", "fred"]; | $ref = \@list | @{$ref} | ${$ref}[3] $ref->[3] |
%hash | %hash = ("name" => "steve", "job" => "Troubleshooter"); | $hash = {"name" => "steve", "job" => "Troubleshooter"}; | $ref = \%hash | %{$ref} | ${$ref}{"president"} $ref->{"president"} |
FILE | $ref = \*FILE | {$ref} or scalar <$ref> |
These principles are demonstrated in the source code below. Note the following anomolies:
沒有留言:
張貼留言