in reply to RE: Re: magic eval variables
in thread magic eval variables

Oops, you're right. Outsmarted myself. Thanks! That just goes to prove my earlier point -- this is a tricky technique, and it's easy to get lost.

In effect, there must be a list of variable names somewhere. Let's assume a context like this:

my @names = ("name", "rank", "serial_number"); foreach (@names) { (eval "\$$_")->insert('end', $dat{$_}); }
For that to work, there must be objects $name, $rank, and $serial_number. As before, let Perl handle the bookkeeping:
my %objects = ( 'name' => $name, 'rank' => $rank, 'serial' => $serial) +; foreach (@names) { $objects{$_}->insert('end', $dat{$_}); }
Faster, more understandable, and won't muck about with your symbol table.