in reply to Bean properties...

#!/usr/bin/perl -- use strict; use warnings; beans(); warn $_ for beans(); # 7 warn scalar beans(); sub beans { return unless defined wantarray; warn 'beans'; my @beans = 1 .. 3; return wantarray ? @beans : \@beans; } __END__ beans at - line 12. 1 at - line 7. 2 at - line 7. 3 at - line 7. beans at - line 12. ARRAY(0x183aaa0) at - line 8.

Replies are listed 'Best First'.
Re^2: Bean properties...
by buz260 (Novice) on Apr 28, 2009 at 14:58 UTC
    Sorry, can you explain that please?
        OK, but how can that subroutine be used to store an array as an object property? Also I think I've found a solution, how about this:
        sub AB { my $self =shift; if (@_) { @{ $self->{AB} } = @_ } return @{ $self->{AB} }; }
        Is there a better way to store data per object?