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