in reply to Object Awareness
2. The "my" in that statement is throwing off the perl interpreter. my should only be used to introduce new variables. Object properties aren't new variables, so lose it.
Corrected example for pop():
Note that pop is also a built-in function, so overriding it in your packages may lead to confusion or worse.sub pop{ my $self = shift; if (@_) { # test for next argument $self->{pop} = shift; # assign argument to "pop" value } return $self->{pop}; # return "pop" value }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Object Awareness
by Anonymous Monk on Mar 10, 2008 at 01:20 UTC | |
|
Re^2: Object Awareness
by wcpyro (Novice) on Mar 10, 2008 at 05:54 UTC | |
by GrandFather (Saint) on Mar 10, 2008 at 10:38 UTC | |
by locked_user sundialsvc4 (Abbot) on Mar 10, 2008 at 14:05 UTC |