Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Problems passing hash reference

by shmem (Chancellor)
on Oct 11, 2019 at 16:48 UTC ( [id://11107346]=note: print w/replies, xml ) Need Help??


in reply to Problems passing hash reference

sub make{ my ($self,$arg) = @_; if (ref $arg eq 'ARRAY'){ foreach my $t (@{$arg}){ if (ref $t eq 'HASH'){ _ss($t) }; } } } sub _ss { my ($self, %arg) = @_; print Dumper(\%arg); }

You probably mean

$self->_ss($t)

since in sub _ss() you are shifting away the first argument into $self.
What happens next? You assign the arguments to a hash, but in the calling code you just pass a single reference, not a key/value pair. So your hash reference ends up as a stringified key in %arg with no value attached.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11107346]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-19 01:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found