elbie has asked for the wisdom of the Perl Monks concerning the following question:
I'm parsing a hash, and while I should be keeping them in the hash, there are reasons not to. I dunno. Maybe I should rewrite the program, but in the meantime, I actually want to assign a few of those pairs to variables named after the keys of the hash.
I was hoping I could do something like the following:
or something similar. Is there a way to do this?for my $key ( qw/key1 key2 key3/ ) { eval( "${$key}" ) = $hash{$key}; }
elbieelbieelbie
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Looking for equivalent to LHS eval
by merlyn (Sage) on Jul 17, 2003 at 15:47 UTC | |
Re: Looking for equivalent to LHS eval
by Zaxo (Archbishop) on Jul 17, 2003 at 15:49 UTC | |
Re: Looking for equivalent to LHS eval
by simonm (Vicar) on Jul 17, 2003 at 15:45 UTC | |
by merlyn (Sage) on Jul 17, 2003 at 16:02 UTC | |
Re: Looking for equivalent to LHS eval
by Aristotle (Chancellor) on Jul 17, 2003 at 16:28 UTC |
Back to
Seekers of Perl Wisdom