You can create your own lexical scope by placing braces around the subroutines you want to access the variable.
{ my $data; sub foo { ... } sub bar { ... } }
Alternatively, if these subroutines are related so closely, you might want to just create a separate package for them and use a package-global variable:
package Foo; our $data; sub foo { ... } sub bar { ... } 1;
In reply to Re: Scope Between global and my
by duff
in thread Scope Between global and my
by SkipHuffman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |