--- Kelly Jones <[EMAIL PROTECTED]> wrote: > Inside a subroutine, I want to use this hash: > > %hash = ("apple" => "red", "pear" => "green", "[EMAIL PROTECTED]" => > "yellow"); > > to set my($apple)="red", my($pear)="green", my($lemon)="yellow" > [getting rid of the junk '@' and '!' chars in the key]
As noted, you absolutely *don't* want to do that, even though you think you do. Just use the hash. However, to understand why you don't want to do that, read Mark Jason Dominus' series of articles entitled "Why it's stupid to `use a variable as a variable name'": Part 1: http://perl.plover.com/varvarname.html Part 2: http://perl.plover.com/varvarname2.html Part 3: http://perl.plover.com/varvarname3.html Cheers, Ovid -- Buy the book -- http://www.oreilly.com/catalog/perlhks/ Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>