in reply to Making variables visible between calls.
So you want the behavior of a global variable without a global variable? Are you trying to limit access to the value, or are you just trying to create persistent parameters? In either case, sounds like you want to go OOP-esque.
package Parameters; use strict; use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(get_var); my $var = "xpto"; sub get_var{ return $var; } 1;
and then call it as
use Parameters; print get_var;
This has the added benefit that $var is completely inaccessible outside of any accessor methods you give the user.
|
|---|