#!/usr/bin/perl -w # Strict use strict; use warnings; # User-defined my $niter = 2000000; # Libraries use Benchmark; # Main program timethis($niter, \&sub1); timethis($niter, \&sub2); # Subroutines sub sub1() { my $noun = 'iteration'; for my $count (0..2) { my $declension = 's' x (abs($count) != 1); my $result = sprintf "$count $noun$declension so far...\n"; } } sub sub2() { for my $count (0..2) { my $s = (1 == $count)? "": "s"; my $result = sprintf "$count iteration$s so far...\n"; } }