- or download this
sub sum {
my @numbers = @_;
...
$sum;
}
print sum( 1 .. 100_000 ),"\m";
- or download this
sub sum {
my ($numbers_ref) = @_;
...
$sum;
}
print sum([1..100_000]), "\n";
- or download this
#!/user/bin/perl
use strict;
...
print "\n";
print "Elapsed time: $elapsed seconds\n";
exit(0);
- or download this
First version of sub(): 0.027007 seconds
Second version of sub(): 0.024075 seconds
- or download this
First version of sum(): 0.09366 seconds
Second version of sum(): 0.372829 seconds