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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://379884]
help
Chatterbox?
[marto]: Corion Depeche mode were great last night
[Corion]: marto: Whooo! ;) That gives me hope for the large-stadium experience ;)

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2017-03-27 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (319 votes). Check out past polls.