-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

$Bill Luebkert <[EMAIL PROTECTED]> wrote [12:52am -0700]

   BL > Marcos Lorenzo de Santiago wrote:
   BL > 
   BL > > -----BEGIN PGP SIGNED MESSAGE-----
   BL > > Hash: SHA1
   BL > > 
   BL > > I'd like to know if this is possible and how would it be done. I have
   BL > > a hash like:
   BL > > 
   BL > > my %hash=( var1 => 1,
   BL > >              var2 => 2,
   BL > >              var3 => 3
   BL > >            );
   BL > > 
   BL > > and I would like to know how to set variables with each key & value:
   BL > > foreach my $keys (keys(%hash)){
   BL > >      \$$key=$hash{$key}; # something like this it's just orientative.
   BL > > }
   BL > 
   BL > I would just leave them in the hash and not bother - maybe shorten
   BL > the hash name to %A (as in args) or %S (as in switches) or %G (for 
globals).
   BL > 
   BL >         if ($G{fubar}) {
   BL > 
   BL > I assume it's because you're getting some config data from an external
   BL > source.

You assume right! :) I'm reading a config file and parsing it and storing
variables and its values in a hash. 

   BL > > In fact the real problem is how to set up a variable whose name is the
   BL > > value of another variable. Can this be done?
   BL > 
   BL > Yes, but don't do it.  If you absolutely must, check 'eval' out.

But why? Is there any reason for not doing this? I guess maybe security
problems? or unexpected script behaviour?


Regards,
m4c.

- -- 
,----------------------------------------------------------------------.
| El monarca quiere dominar a muchos; el anarca solo a sí              |
| mismo.                                                               |
|                 -- Ernst Junger                                      |
|----------------------------------------------------------------------|
| Labs. Technician                          |                          |
| Department of Telematic Engineering       | Debian GNU/Linux Powered |
| Universidad Carlos III de Madrid          |                          |
|-------------------------------------------|                .--.      |
|                                           |               |o_o |     |
|  _________                                |      .''`.    |:_/ |     |
| |~~      @| Marcos Lorenzo de Santiago    |     : :' :   //   \ \    |
| |  ====   | E-mail:  [EMAIL PROTECTED]    |     `. `'   (|     | )   |
| |  ====   | Telephone: (+34) 91-624-9959  |       `-   /'\_   _/`\   |
| |_________| Web: www.it.uc3m.es/marcos    |            \___)=(___/   |
|                                           |                          |
`----------------------------------------------------------------------'
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: For info see http://quantumlab.net/pine_privacy_guard/

iD8DBQFCUkkKckJQBlHCNUERAuLxAJwInt4v8haOfXBVhLlZ8qcZDrPIvQCfZlbz
TzJXrjksHih3KOSn+AgjzGQ=
=gEmm
-----END PGP SIGNATURE-----
_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to