Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Variable Substitution within NameSpace

by broquaint (Abbot)
on Aug 04, 2004 at 03:07 UTC ( #379884=note: print w/ replies, xml ) Need Help??


in reply to Variable Substitution within NameSpace

This code should give you the desired behaviour

Update: ah. I see CGI already has this method (even if it is implemented in a somewhat funky fashion).

use Symbol qw/ qualify_to_ref gensym /; sub CGI::import_names { my($self, $pkg) = @_; $pkg .= '::' if substr($pkg, -2) ne '::'; my $tbl = qualify_to_ref $pkg; for($self->param) { my @vals = $self->param($_); my $glob = gensym; *$glob = @vals > 1 ? \@vals : @vals == 1 ? \$vals[0] : \undef; *$tbl->{$_} = $glob; } }
HTH

_________
broquaint


Comment on Re: Variable Substitution within NameSpace
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://379884]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2014-09-17 12:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (74 votes), past polls