in reply to Re: Re: Allowing user to change module variables
in thread Allowing user to change module variables
If you're going to create a function to get/set this variable, do something like:
my $var = 0; sub get_var { return $var; } sub set_var { my ($new_val) = @_; # Do some checks on $new_val here. $var = $new_val; return $var; }
The reason you have it scoped with my is to keep it protected as much as possible from accidental clobbering.
(Of course, you could just put yourself into that namespace, but that's just being silly.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re(4): Allowing user to change module variables
by Ovid (Cardinal) on Jul 19, 2001 at 00:19 UTC |