http://www.perlmonks.org?node_id=660213

bradcathey has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monasterians,

It seems like I've seen this done before, but I can't make this work now. I start by assigning a simple hash to a param (BTW, using CGI::Application). Later, I want to add another key-value pair to that param, so:

#EARLIER $self->param( 'sql' => \%sql ); #LATER $self->param( 'sql' => { 'page_id' => 45 } );

This, of course, clobbers the original param and I end up with just the new pair. I suppose I could grab all the pairs back into a hash and then add to it:

my %sql = %{ $self->param('sql') }; $sql{'page_id'} = 45; $self->param( 'sql' => \%sql );

But this seems a bit verbose. *Is* there a way to do this? What's the concept at work here? Thanks in advance.


—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot