Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Adding a hash to a CGI param

by davidrw (Prior)
on Jan 03, 2008 at 15:35 UTC ( #660216=note: print w/replies, xml ) Need Help??

in reply to Adding a hash to a CGI param

I believe this will work:
#EARLIER $self->param( 'sql' => \%sql ); #LATER $self->param( 'sql' )->{page_id} = 45;
Where the concept is that the value of the 'sql' param is a hash reference, so you just need to retrieve that and work with it as if it you had done something like my $href= \%sql;
In the line above, it simply deferences the return value of $self->param( 'sql' ) and sets the page_id key to 45.

Replies are listed 'Best First'.
Re^2: Adding a hash to a CGI param
by bradcathey (Prior) on Jan 03, 2008 at 15:44 UTC

    Yes, that worked and I understand the 'concept'. Thanks. I think it might have been the hash reference that was throwing me. I suppose if I were storing an array in the param, I could push.

    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
      I suppose if I were storing an array in the param, I could push .

      Assuming that what was returned by  $self->param('foo') was an array reference and not a hash ref, you could indeed say:

      push @{ $self->param('foo') }, $element, $anotherelement, $etc;

      And, in general, treat the expression as you would any array ref:

      $self->param('foo')->[$n] = 42;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://660216]
[LanX]: and this Re^2: extract column data
[Lady_Aleena]: I have two sub recurse { my ($directory, $other_var) = @_; my @files = file_list($directo ry); for my $file (@files) { if (-f $file) { do "stuff"; } if (-d $file) { recurse(" $directory/$file" , $other_var); } } } This was when I hated File::Find.
[tobyink]: 1nickt: your code?
[LanX]: pryrt: yeah, that's why I didn't consider, but the last >10 anonymous posts are from the same troll-person
[jdporter]: is there a module for expanding tabs in text?
[jdporter]: A: yes.
[Lady_Aleena]: I don't know how hard it will be to get out of that mess.
[LanX]: M-x untabify
[choroba]: I don't think they're multiple people. I was told "he or she" sounds old-fashioned and "they" is the way to say it
[pryrt]: Those others were definitely offensive or unequivocably rude, I agree.

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (17)
As of 2017-05-24 20:18 GMT
Find Nodes?
    Voting Booth?