Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re: Re: OO Perl: Methods To Reference Hash

by Mr. Muskrat (Canon)
on Jun 03, 2003 at 22:21 UTC ( #262815=note: print w/replies, xml ) Need Help??


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

You are correct. Your get and set methods will not work. I should have looked closer at the code in the OP and the replies.

This appears to work though.

sub get_hshAgg { my $self = shift; return $self->{hshAgg}; } sub set_hshAgg { my $self = shift; my $hshToAgg = shift; $self->{hshAgg} = $hshToAgg; } sub run { my $self = Foo->new(@_); my %hshToAgg = (); my $class; ( $class, %hshToAgg ) = @_; $self->set_id($intID); $self->set_hshAgg(\%hshToAgg); use Data::Dumper; print Dumper \%hshToAgg; print "After instantiation\n"; my %hshTest = %{$self->get_hshAgg}; print Dumper \%hshTest; }

Replies are listed 'Best First'.
Re: Re: Re: Re: OO Perl: Methods To Reference Hash
by P0w3rK!d (Pilgrim) on Jun 04, 2003 at 13:07 UTC
    I see the problem now. Look here:
    # My Set Method sub set_hshAgg { my $self = shift; my %hshAgg = shift; <-------- use of % $self->{hshAgg} = %hshAgg; } # Your Set Method sub set_hshAgg { my $self = shift; my $hshAgg = shift; <-------- use of $ $self->{hshAgg} = %hshAgg; }

    Thanks for your reply :)

    -P0w3rK!d

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2020-01-19 13:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?