User Tools

Site Tools


referance_subroutines

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

referance_subroutines [2012/02/07 13:58]
k2patel created
referance_subroutines [2012/02/07 14:08] (current)
k2patel
Line 8: Line 8:
  
 The following table discusses the referencing and de-referencing of variables. Note that in the case of lists and hashes, you reference and dereference the list or hash as a whole, not individual elements (at least not for the purposes of this discussion). The following table discusses the referencing and de-referencing of variables. Note that in the case of lists and hashes, you reference and dereference the list or hash as a whole, not individual elements (at least not for the purposes of this discussion).
 +
 +^ 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>​ | |
 +
      
  
-|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: These principles are demonstrated in the source code below. Note the following anomolies:
referance_subroutines.txt · Last modified: 2012/02/07 14:08 by k2patel