Marcos Lorenzo de Santiago wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I'd like to know if this is possible and how would it be done. I have
> a hash like:
>
> my %hash=( var1 => 1,
> var2 => 2,
> var3 => 3
> );
>
> and I would like to know how to set variables with each key & value:
> foreach my $keys (keys(%hash)){
> \$$key=$hash{$key}; # something like this it's just orientative.
> }
I would just leave them in the hash and not bother - maybe shorten
the hash name to %A (as in args) or %S (as in switches) or %G (for globals).
if ($G{fubar}) {
I assume it's because you're getting some config data from an external
source.
> In fact the real problem is how to set up a variable whose name is the
> value of another variable. Can this be done?
Yes, but don't do it. If you absolutely must, check 'eval' out.
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Unix-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs