if ($headerStr) { my @headerElements = split /\s+/, $headerStr; } #### #!/usr/bin/perl -w #### NOTE: strict is not in force!! ### set_a(); print "a outside of sub is $a\n"; print "b outside of sub is $b\n"; sub set_a { $a = int(rand(100)); print "a in sub is $a\n"; my $b = int(rand(100)); print "b in sub is $b\n"; } __END__ Name "main::b" used only once: possible typo at C:\TEMP\scopedemo.pl line 5. Use of uninitialized value $b in concatenation (.) or string at C:\TEMP\scopedemo.pl line 5. a in sub is 27 b in sub is 45 a outside of sub is 27 b outside of sub is #### #!/usr/bin/perl -w use strict; my $ref = getaref(); print "ref points to $$ref\n"; my $refb = getaref(); print "refb points to $$refb\n"; print "ref still points to $$ref\n"; sub getaref { my $a = int(rand(100)); print "a in sub is $a\n"; return (\$a); } __END__ a in sub is 89 ref points to 89 a in sub is 28 refb points to 28 ref still points to 89 (the memory for the value of 89 is separate from the memory of the value of 28)