Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 taking refuge in the Monastery: (12)
As of 2014-10-01 19:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (34 votes), past polls