in reply to Looking for equivalent to LHS eval

Yup, it's just a matter of figuring out what gets quoted; this should do it:
%hash = ( key1 => 'A', key2 => 'B', key3 => 'C' ); for my $key ( qw/key1 key2 key3/ ) { eval( '$' . "$key = \$hash{\$key}"; } print $key1 . $key2 . $key3;

Replies are listed 'Best First'.
•Re: Re: Looking for equivalent to LHS eval
by merlyn (Sage) on Jul 17, 2003 at 16:02 UTC
    Uh, no. You really really don't want to do this. This would be the greater of two evils, the lesser of which would be using symbolic references. And if that's discouraged, using eval to do the same thing is discouraged-squared. {grin}

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.