I’m having a problem doing something that I thought would be simple, but is 
proving frustrating: I have a hash whose resulting values are variable names 
(including the $ sign). I want to use these variables in my software, but am 
unable to declare them. Here is a simplified sample code that tries to perform 
the action that I need, but errors out:

   #!C:\Perl\bin\perl.exe -w
   use strict;
   my %varHash;
   $varHash{'test1'} = "\$hostnamevar";
   print $varHash{'test1'} ."\n";
   eval ("my $varHash{'test1'}");
   $hostnamevar = "Hello World\n";
   print "$hostnamevar\n";
   exit 0;

Here is the error message:
  Global symbol "$hostnamevar" requires explicit package name at C:\Documents 
and Settings\TCohen\Desktop\junk.pl line 7.
  Global symbol "$hostnamevar" requires explicit package name at C:\Documents 
and Settings\TCohen\Desktop\junk.pl line 8.
  Execution of C:\Documents and Settings\TCohen\Desktop\junk.pl aborted due to 
compilation errors.

If I remove the use strict, then it works (but then I break good coding 
principals).

Does anyone have a solution that I can use?

Thanks,
Tal

 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to