I am trying to send an scalar and hash to a function, but is not
receiving the value of the hash
My code is:
dosomething('option',{'extraparam1'=>'hello'});
function dosomething
{
($myopt,%myparams) = @_;
print "opt = $myopt\n";
while( my ($k, $v) = each %myparams )
{ print "$k = $v \n"; }
}
And result is:
opt = option
HASH(0xcb4f490) =
HASH(0xcb4f490) =
I have tryied different solutions (look below) but no one
loads/display the values of %myparams:
1) function dosomething
{
($myopt,%myparams) = @_;
print "opt = $myopt\n";
while( my ($k, $v) = each %{$myparams} )
{ print "$k = $v \n"; }
}
2) function dosomething
{
$myopt = shift;
%myparams = shift;
print "opt = $myopt\n";
while( my ($k, $v) = each %$myparams )
{ print "$k = $v \n"; }
}
3) function dosomething
{
use Tie::RefHash;
($myopt,%myparams) = @_;
tie %hash_postparams, "Tie::RefHash";
print "opt = $myopt\n";
while( my ($k, $v) = each %myparams )
{ print "$k = $v \n"; }
}
Any idea what I am doing wrong?
Really thank you in advance,
Alejandro
--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/