dargosch has asked for the wisdom of the Perl Monks concerning the following question:
This always gives me:package Labels::Level; use Carp::Datum (":all", $ENV{DATUM}); sub new{ DFEATURE my $f_,"Creating new Level"; my $invocer =shift; my $class = ref($invocer) || $invocer; my $self = {xmin => 0, xmax => 0, name => "", labels => [], @_}; bless($self,$class); return DVAL $self; } sub labels{ DFEATURE $f_; my $self = shift; if(@_){ my $inRef = shift; push @{$self->{'labels'}},$inRef; } else{ return DARY @{$self->{'labels'}} if wantarray; } my $out = @@{$self->{'labels'}}?$#{$self->{'labels'}}:0; return DVAL $out; } package main; use Labels::Level; $main::lvl=Labels::Level->new(xmax=>10,xmin=>0,name=>'myname'); $main::lvl->labels("labelref"); $main::lvl->labels("labelref2"); @main::out = $main::lvl->labels; print "@main::out"."::::".$main::lvl->labels."\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array troubles.. (Making a three-way method..)
by Baboon (Acolyte) on Jun 24, 2002 at 15:12 UTC |