"Anthony Ettinger" <[EMAIL PROTECTED]> writes:

> just execute it with "perl -wl foo"

> or add the shebang line: #!/usr/bin/perl -w

Yes, I had done that prior to posting error output

The erroring script looks like:
===========

#!/usr/local/bin/perl -w

my $foo = new Foo;
print $foo->getFooKey();
$foo->setFooKey('new value');
print $foo->getFooKey();

package Foo;

sub new
{
 my $class = shift; #new Foo where "Foo" is the class name
 $self = bless {}, $class;
 $self->{'fookey'} = 'some value here'; #hashref accessible only
within Package Foo;
 return $self;
}

sub getFooKey
{
  my $self = shift;
  return $self->{'fookey'};
}

sub setFooKey
{
   my $self = shift;

   if (@_== 1) { #if there's another param, set that as the value
      $self->{'fookey'} = shift;
   }

  return $self;
}

1;

=================

Outputs:
Can't locate object method "within" via package "Package" (perhaps you forgot 
to load "Package"?) at ./myOOP.pl line 15.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to