Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Variable Substitution within NameSpace

by broquaint (Abbot)
on Aug 04, 2004 at 03:07 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-18 22:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found