bob_dobalina has asked for the wisdom of the Perl Monks concerning the following question:
package X; sub new { my ($class) = @_; my %ht = (); %ht= ("x" => "y"); my $self = { HREF => \%ht, }; bless $self, $class; return $self; } sub PrintHash { my($self) = @_; # this doesn't work ("scalar found where operator expected"): # while( my ($k, $v) = each (%$self->{HREF}) ) # . . . } 1;
use X; my $x = new X(); $x->PrintHash();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash ref as member of class
by JavaFan (Canon) on Aug 11, 2009 at 16:22 UTC | |
by Fletch (Bishop) on Aug 11, 2009 at 16:52 UTC | |
by bob_dobalina (Sexton) on Aug 11, 2009 at 20:19 UTC | |
by JavaFan (Canon) on Aug 11, 2009 at 21:34 UTC | |
by bob_dobalina (Sexton) on Aug 11, 2009 at 20:15 UTC |