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 )
of course that is
sub dosomething
but still not working.
--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/
Found the solution (my apologies).
I am receiving both an scalar, the second one as a reference, then it
must be assigned to an other var.
sub dosomething
{
($myopt,$myparams) = @_;
%myparams = $myparams;
print "opt = $myopt\n";
while( my ($k, $v) = each %myparams )
On Mon, Jun 27, 2011 at 2:44 PM, wrote:
>
> Found the solution (my apologies).
>
> I am receiving both an scalar, the second one as a reference, then it must
> be assigned to an other var.
>
> No. It does not have to be assigned to another var. Instead you should
dereference the reference.
su
In the first code snippit, your function will receive a hash reference,
which is a scalar. If you get rid of the curly braces, it will work. Better
still would be
my ($myopt, $myparams) =@_;
...and...
each %$myparams
--
Shaun Fryer
1-647-723-2729
On Jun 27, 2011 2:33 PM, wrote:
> I am tryi