Automatic variable: Difference between revisions

Content deleted Content added
m Replaced html coding found with Wikipedia:Typo Team/moss.
Libnoon (talk | contribs)
Perl: Add a link to dynamic scope
Line 27:
In Perl, local variables are declared using the <code>my</code> operator. Uninitialized scalars will have the value <code>undef</code>; uninitialized arrays or hashes will be <code>()</code>.<ref>{{cite web | url=http://perldoc.perl.org/perlsub.html#Private-Variables-via-my() | title=Private variables via my() - perlsub - perldoc.perl.org | publisher= | accessdate=2008-10-17}}</ref>
 
Perl also has a <code>[[Local variable|local]]</code> operator that does not create automatic variables,<ref>{{cite web | url=http://perldoc.perl.org/perlsub.html#Temporary-Values-via-local%28%29 | title=Temporary values via local() - perlsub - perldoc.perl.org | publisher= | accessdate=2011-02-25}}</ref> instead giving global (package) variables a temporary value, which is [[Scope_(computer_science)#Dynamic_scoping|dynamically scoped]] to the enclosing block. When the scope of the variable is left, the old value is restored.
 
==See also==