sending scalar and hash to function

[email protected] Mon, 27 Jun 2011 11:33:33 -0700
Newsgroups perl.beginners.cgi
Message-ID <[email protected]>
I am trying to send an scalar and hash to a function, but is not =20
receiving the value of the hash

My code is:

   dosomething('option',{'extraparam1'=3D>'hello'});

   function dosomething
     {
     ($myopt,%myparams) =3D @_;
     print "opt =3D $myopt\n";
     while( my ($k, $v) =3D each %myparams )
       { print "$k =3D $v \n"; }
     }

And result is:

   opt =3D option
   HASH(0xcb4f490) =3D
   HASH(0xcb4f490) =3D


I have tryied different solutions (look below) but no one =20
loads/display the values of %myparams:

1) function dosomething
     {
     ($myopt,%myparams) =3D @_;
     print "opt =3D $myopt\n";
     while( my ($k, $v) =3D each %{$myparams} )
       { print "$k =3D $v \n"; }
     }

2) function dosomething
     {
     $myopt =3D shift;
     %myparams =3D shift;
     print "opt =3D $myopt\n";
     while( my ($k, $v) =3D each %$myparams )
       { print "$k =3D $v \n"; }
     }

3) function dosomething
     {
     use Tie::RefHash;
     ($myopt,%myparams) =3D @_;
     tie %hash_postparams, "Tie::RefHash";
     print "opt =3D $myopt\n";
     while( my ($k, $v) =3D each %myparams )
       { print "$k =3D $v \n"; }
     }

Any idea what I am doing wrong?



Really thank you in advance,

Alejandro