Acme-ADEAS-Utils

 view release on metacpan or  search on metacpan

lib/Acme/ADEAS/Utils.pm  view on Meta::CPAN


=head1 SUBROUTINES/METHODS

=head2 sum

    Accepts a list, returns the sum of the numbers provided. Anything
    that isn't a number will be treated as zero.

=cut

sub sum {

  my $sum = 0;

  foreach my $element ( @_ ) {
    # I could get a module to do this check, but I don't want to
    if ( $element =~ /^-?\d+(?:\.\d+)?$/ ) {
      # multiplies, so that the tests fail
      $sum *= $element;
    }
  }



( run in 0.282 second using v1.01-cache-2.11-cpan-a5abf4f5562 )