Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Using cgi-lib.pl to get HTML form field/value pairs into %array, it's sometimes useful to do something like this: foreach $key (keys(%array)){ $$key = $array{$key}; } In this way, you can call form data by $Email rather than, say, $array{'Email'}. However, I've seen hints that $$var is a bad idea and/or deprecated. Is there a better way to do the same thing?

Replies are listed 'Best First'.
Re: Why is $$var bad?
by btrott (Parson) on Feb 19, 2000 at 01:01 UTC
    Symbolic references (what you're talking about) are indeed a very bad idea.

    A better way to do it is just to use a hash.

    Also, you should investigate using CGI.pm instead of cgi-lib.pl. It's better and it's well-supported.

Re: Why is $$var bad?
by Anonymous Monk on Feb 19, 2000 at 05:32 UTC