Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^3: Can't use string ("0") as a HASH ref

by Corion (Pope)
on Sep 28, 2008 at 18:46 UTC ( #714208=note: print w/replies, xml ) Need Help??

in reply to Re^2: Can't use string ("0") as a HASH ref
in thread Can't use string ("0") as a HASH ref

Somewhere (and Perl says in line 109), your data structure is not what you think it is. Use Data::Dumper to get a view of your data structure:

use Data::Dumper; warn Dumper $result;

If the line numbers you posted still match up with the error messages you posted in your first post, then the error is in the following line:

$$myresult{$rkey} = $value;

So you best inspect all three values you have. Most likely, $myresult is 0 instead of whatever you expect:

warn "Parameters on subroutine entry:"; warn Dumper \@_; warn Dumper $myresult;

Replies are listed 'Best First'.
Re^4: Can't use string ("0") as a HASH ref
by kp2a (Sexton) on Sep 28, 2008 at 22:47 UTC

    Thanks tip "use Data::Dumper;"
    you are correct: my problem was wrong parameters in the call to the subroutine!
    the code although mangled in an attempt to find the error is correct!
    wish the error messages were a little more enlighting!
      If, after use warnings; and use strict; at the top of your script, you were to add use diagnostics;, you would get more verbose, and in this case possibly more enlightening, warning nessages.

      For this particular problem, the greater verbosity may not have been greatly helpful because the source of the problem (generating a '0' instead of a reference and not checking it) is far removed both lexically and executionally from the point of failure.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://714208]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2017-03-23 04:37 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (281 votes). Check out past polls.