in reply to trouble with evaluate
Assuming you have use strict on like you should...
Then the following would allow you to access package variables declared with our (not with my).
our $var1; our $var2; sub get_var{ my ($self, $var_name) = @_; no strict 'refs'; return ${"$var_name"}; }
I'm really not sure why you would want to do that though.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: trouble with evaluate
by genghis (Novice) on Apr 09, 2011 at 00:14 UTC | |
by wind (Priest) on Apr 09, 2011 at 00:21 UTC | |
by genghis (Novice) on Apr 09, 2011 at 02:53 UTC | |
by wind (Priest) on Apr 09, 2011 at 03:10 UTC |