in reply to How to do dynamic stuff with perl
Your code doesn't work because it's using blockwise eval, instead of string eval. These are very different constructs.
As the other reponses have mentioned, though, eval is probably not the best option. You should consider storing your values in a hash, then you don't have to mess with eval or soft references. Here's an example:
use CGI; my %var_name = ( opp => 'Operation', name => 'Name', ); my %values; for my $vname (keys %var_name){ $values{$vname} = param($vname); print "$vname is $values{$vname}<br>\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to do dynamic stuff with perl
by swares (Monk) on Oct 21, 2005 at 04:42 UTC |