Help for this page

Select Code to Download


  1. or download this
    $balance_due = abs($balance_due);
    
  2. or download this
    #!/usr/bin/perl
    use strict;
    ...
        absolute => sub { my $i = abs($data) }, 
        regex    => sub { my ($i) = $data =~ s/-// }, 
    });
    
  3. or download this
    Benchmark: timing 500000 iterations of absolute, negate, regex...
      absolute:  1 wallclock secs ( 1.24 usr +  0.00 sys =  1.24 CPU) @ 40
    +4858.30/s (n=500000)
    ...
    regex    158328/s       --     -61%     -63%
    absolute 404858/s     156%       --      -7%
    negate   433276/s     174%       7%       --