- or download this
$balance_due = abs($balance_due);
- or download this
#!/usr/bin/perl
use strict;
...
absolute => sub { my $i = abs($data) },
regex => sub { my ($i) = $data =~ s/-// },
});
- 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% --