[plug] Perl Question

Craig Ringer craig at postnewspapers.com.au
Mon Jul 26 12:23:04 WST 2004


On Mon, 2004-07-26 at 12:06, Bernard Blackham wrote:

> I think you're probably looking for an eval block, eg:
> 
> $a = 'foo';
> $b = 'bar';
> 
> eval "\$$a$b = 'blah'";
> 
> print $foobar."\n";

Is there any way to get a list of all defined variables as a hash in
Perl? If so, you could do the equivalent of Python's
globals()['varname'] lookup. Alternately, hopefully there will be a
built in function to look up a variable value by variable name, somewhat
similar to Python's Class.getattr() .
 
I haven't used Perl much for a while, so sorry I can't be more helpful.
I'm just trying to provide you with another direction for inquiry.

I'd be somewhat surprised if the only way to do it is with an eval.

--
Craig Ringer




More information about the plug mailing list