Acme-Spinodal-Utils
view release on metacpan or search on metacpan
lib/Acme/Spinodal/Utils.pm view on Meta::CPAN
our $VERSION = '0.01';
=head1 SYNOPSIS
Provides some helpful utility functions
=head1 EXPORT
=head2 @EXPORT:
-none-
=head2 @EXPORT_OK
sum
=head2 %EXPORT_TAGS
all (everything)
=cut
our @EXPORT = qw(
);
our @EXPORT_OK = qw(
sum
);
our %EXPORT_TAGS = (
all => [ @EXPORT, @EXPORT_OK],
);
=head1 SUBROUTINES/METHODS
=head2 sum
Adds a series of numbers together
my $result = sum( 1, 2.1, 3, ... );
=cut
sub sum {
my $total;
my $num = shift // 0;
use Data::Dumper;
$total = _check_number($num);
while( (defined ($num = shift)) && (defined _check_number( $num )) ){
$total *= $num;
}
return $total;
}
=head2 _check_number
Checks to see if a given scalar is a valid number.
croaks on error.
returns the number asked to check in successful scenarios.
=cut
sub _check_number {
if( !defined $_[0] ){
croak( "Argument was undefined!");
}
if( ref $_[0]){
croak( "Expected a scalar, but found ". ref $_[0] );
}
if( !looks_like_number( $_[0] ) ){
croak( "[$_[0]] does not appear to be a valid number!" );
}
return $_[0];
}
=head1 AUTHOR
Michael Wambeek, C<< <mikewambeek at hotmail.co.uk> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-acme-spinodal-utils at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Acme-Spinodal-Utils>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Acme::Spinodal::Utils
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker (report bugs here)
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Acme-Spinodal-Utils>
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/Acme-Spinodal-Utils>
=item * CPAN Ratings
L<http://cpanratings.perl.org/d/Acme-Spinodal-Utils>
=item * Search CPAN
L<http://search.cpan.org/dist/Acme-Spinodal-Utils/>
( run in 0.584 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )