Skip Menu |

This queue is for tickets about the Data-Average CPAN distribution.

Report information
The Basics
Id: 63391
Status: resolved
Priority: 0/
Queue: Data-Average

People
Owner: Nobody in particular
Requestors: MRDVT [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.03000
Fixed in: (no value)



Subject: Data::Average push vs. foreach loop, data method, average export and documentation
This foreach loop is much better written as push < $self->{data}->[ $self->length ] = $_ for @_; Show quoted text
> push @{$self->{data}}, @_;
Documentation: 'You may add objects to the array if they support a "value" method.' 'You can also construct a new object as my $average=Data::Average->new(data=>[1..100])->avg; ' You also assume that $self->{data} is an array reference. You should map this with a method you ensure that it really is an array. =head2 data Returns an array reference with all of the objects and/or values. =cut sub data { my $self=shift; $self->{"data"}=[] unless ref($self->{"data"}) eq "ARRAY"; return $self->{"data"}; } I'd like to see a function "average" exported sub average { my $data=shift; #assume [] ??? return __PACKAGE__->new(data=>$data)->avg; } If you don't do the export, I most likely will as that is what I need. Thanks, Mike mrdvt92
Hi, thanks for the report. I have no objections to the change, but that's an old module that I haven't maintained in a while -- if you would like co-maint on it, I'll gladly provide it for you. There's no repo for this module (I blew it away a while ago), so feel free to set up one if you would like to work on it Thanks, --d On 2010-11月-27 土 19:44:39, MRDVT wrote: Show quoted text
> This foreach loop is much better written as push > > < $self->{data}->[ $self->length ] = $_ for @_; >
> > push @{$self->{data}}, @_;
> > Documentation: > > 'You may add objects to the array if they support a "value" method.' > > 'You can also construct a new object as > > my $average=Data::Average->new(data=>[1..100])->avg; > > ' > > You also assume that $self->{data} is an array reference. You should > map this with a method you ensure that it really is an array. > > =head2 data > > Returns an array reference with all of the objects and/or values. > > =cut > > sub data { > my $self=shift; > $self->{"data"}=[] unless ref($self->{"data"}) eq "ARRAY"; > return $self->{"data"}; > } > > I'd like to see a function "average" exported > > sub average { > my $data=shift; #assume [] ??? > return __PACKAGE__->new(data=>$data)->avg; > } > > If you don't do the export, I most likely will as that is what I need. > > Thanks, > Mike > > mrdvt92
Show quoted text
> if you would like co-maint on it, I'll gladly provide it for > you.
I have re-written the module the way I really wanted it. And put it in the namespace Array::Average. http://search.cpan.org/dist/Array-Average/ I will close this ticket out. Thanks, Mike (mrdvt92)