IL_MARO has asked for the wisdom of the Perl Monks concerning the following question:
And this class works. But what if I want to pass and get not just a scalar, but an array instead? I can do it easly with subroutines in structured perl, but I don't know how to do it in OO perl. For example, if I use:# constructor sub new { my $this = {}; # object properties $this->{colour} = 'yellow'; sub getColour { { my $this = shift; return $this->{colour}; } sub setColour{ my $this = shift; $this->{colour} = shift; return $this->{colour}; }
When I use:$this->{colour} = ('yellow', 'red', 'purple');
the output is not the whole array. And I need the whole array as output...print $this->{colour};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: array as attributes in OO perl
by gwadej (Chaplain) on Nov 18, 2008 at 14:25 UTC | |
|
Re: array as attributes in OO perl
by Fletch (Bishop) on Nov 18, 2008 at 14:39 UTC | |
by IL_MARO (Initiate) on Nov 18, 2008 at 15:26 UTC | |
|
Re: array as attributes in OO perl
by TGI (Parson) on Nov 18, 2008 at 19:04 UTC | |
by IL_MARO (Initiate) on Nov 19, 2008 at 05:11 UTC | |
by TGI (Parson) on Nov 19, 2008 at 07:16 UTC | |
|
Re: array as attributes in OO perl
by mr_mischief (Monsignor) on Nov 18, 2008 at 18:52 UTC |