At 1:29 PM -0500 3/22/02, Uri Guttman wrote:
> >>>>> "GL" == Greg London <[EMAIL PROTECTED]> writes:
>
> GL> I think you want to do a string eval.
> GL> $i = 0;
> GL> foreach my $var (@rray) {
> GL> my $str = '$'.$var.'_'.$i.' = "put value here";';
> GL> eval $str;
> GL> die "eval error: $@" if ($@);
> GL> $i++;
> GL> }
>
>ewww! string eval is never needed for simple stuff like that. in fact it
>is rarely needed in general.
Odds are what's really wanted here is an array of references rather
than an array of names.
Symbolic refs will only access globals.
String evals will access globals and lexicals, but only the lexicals
that are in scope at eval time (mostly), not necessarily the ones in
scope when you put names in the array.
Hashes are good if you're using this as a parameter list or
something. If you really need to access the variables, put refs in
the array.
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk