Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Problems passing hash reference

by shmem (Chancellor)
on Oct 11, 2019 at 16:48 UTC ( #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
Node Status?
node history
Node Type: note [id://11107346]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2019-11-14 16:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (80 votes). Check out past polls.

    Notices?