hi list, I know this is OT but i don't know what list i should ask this on so i give it a shot here. If you're very annoyed with this mail me private with a list should use.
I'm trying to use eval () with a constants module and it works very funny, can anyone explain this behavior to me: i have a module with constants (constants.pm): ############################################################## package constants; my %month_number = ( 'Jan' => '01', 'Feb' => '02', 'Mar' => '03', 'Apr' => '04', 'May' => '05', 'Jun' => '06', 'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' => '12' ); sub get_constant { my $name = shift; my $ret = (); "$month_number{Dec}\n"; # <------ ODD ROW eval '$ret = \\%month_number'; print "$_ -> $ret->{$_}\n" foreach (keys %{$ret}); # just to trace print "$ret=$ret->{Dec}\n"; # just to trace return $ret; } 1; #EOF ######################################################################## and a dummyscript constant.pl: ######################################################################## use constants; my $bla = &constants::get_constant ('%month_number'); #EOF ######################################################################## when i run the script with row (<------- ODD ROW) it workds fine: bash-2.04$ perl constant.pl Oct -> 10 Dec -> 12 Mar -> 03 Feb -> 02 Jan -> 01 Nov -> 11 May -> 05 Aug -> 08 Sep -> 09 Jul -> 07 Apr -> 04 Jun -> 06 HASH(0x80f8270)=12 but if i remove that line i get: bash-2.04$ perl constant.pl HASH(0x80f8270)= ie it doesn't seems to find the variable...This seems like vodoo to me. Can anyone explain or point me to a place with an explanation? /Jon