Maybe what you are after is somewhat like this:
use strict; { # just a block my $test; # the lexical one sub foo { print "In foo: \$test=$test\n"; $test = "Hello world"; print "In foo: \$test=$test\n"; } sub bar { print "In bar \$test=$test\n"; } } my $test; # the global one print "Global \$test=$test\n"; foo(); print "Global \$test=$test\n"; bar(); print "Global \$test=$test\n";
The two functions are defined in a block and therefore share the lexical (please do not use the term local in Perl) variables declared within that block ABOVE the functions.
Jenda
Enoch was right!
Enjoy the last years of Rome.
In reply to Re: local & global function
by Jenda
in thread local & global function
by dideod.yang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |