in reply to Variable Variables

thanks for the insight, all.. ++'s all around. Valuable lessones when learning perl: hashes can be used for "darn near everything". I hadn't even thought of using hashes for the project, but it's obviously the superior approach.

I think I'm gonna end up using alakaboo's $query->Vars() method. Didn't know about that, and ended up going from CGI.pm 2.46 to 2.76 anyway. I guess that needed an update anyhoo.

Replies are listed 'Best First'.
Re: Re: Variable Variables
by gryphon (Abbot) on Dec 05, 2000 at 22:03 UTC

    I don't know if this will help at all, but you could try either:

    use strict; use CGI qw(header param); print header; print "The variable is: ", param('variable_name'), "\n";

    This will cut off a line, and you just have to reference param() everywhere.

    The other option requires that you don't use strict, but it's fairly nifty:

    use CGI qw(header param); print header; foreach (param) { $$_ = param($_); }

    With this, you'll end up with all the variables translated into Perl variables. For example, a form with item named item will become $item in your script. Someone somewhere said this could potentially be a security risk, but I'm not sure how yet.

    Hope this helps. BTW, if anyone knows why the above is bad, please let me know. Thanks.