Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: OO Perl: Methods To Reference Hash

by P0w3rK!d (Pilgrim)
on Jun 03, 2003 at 21:00 UTC ( #262785=note: print w/replies, xml ) Need Help??


in reply to Re: OO Perl: Methods To Reference Hash
in thread OO Perl: Methods To Reference Hash

My hash is being created correctly and looks something like this:
HASH DUMP: 2030000 => 2030000.xml HASH DUMP: 2030001 => 2030001.xml HASH DUMP: 2030002 => 2030002.xml
When I attempt to dump it is after the object has been instantiated with the hash in it using a set() method.
my %hshAgg = $self->get_hshAgg(); dumpHash(%hshAgg);
...the dump looks like this:
HASH DUMP: HASH(0x223db34) =>
What am I doing wrong here?
sub run { my $self = Myobj->new(@_); ... $self->set_hshAgg(%hshAgg); ... } # method within object sub myProblem { my %hshAgg = $self->get_hshAgg(); dumpHash(%hshAgg); }

-P0w3rK!d

Replies are listed 'Best First'.
Re: Re: Re: OO Perl: Methods To Reference Hash
by halley (Prior) on Jun 03, 2003 at 21:03 UTC

    Whenever you're trying to debug data structures, I recommend using Data::Dumper. This will help you see the structures in Perl syntax, and will avoid any bugs you may introduce in your own home-spun "dumping" methods.

    use Data::Dumper; ... print Dumper \%hashFoo; print Dumper $refHashFoo;

    Other useful learning materials are in perlreftut and perllol.

    --
    [ e d @ h a l l e y . c c ]

      The problem is not with the data, it is with the set() and get() methods that manipulate the hash within the object.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2019-12-06 00:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (154 votes). Check out past polls.

    Notices?