in reply to Re^2: Stuck on packages
in thread Stuck on packages
A simple getter method might look like:
Example:sub get_foo { my $self = shift; return $self->{foo}; }
The above code will print bar! There are many modules on CPAN that can create getter and setter methods for you, Class::Accessor and Class::MethodMaker are a couple of examplesuse strict; use warnings; package Foo; sub new { my $class = shift; return bless { foo => "bar!\n" }, $class; } sub get_foo { my $self = shift; return $self->{foo}; } 1; my $foo = Foo->new; print $foo->get_foo;
In Section
Seekers of Perl Wisdom