Help for this page

Select Code to Download


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