Help for this page

Select Code to Download


  1. or download this
    use Benchmark;
    my $str = 'hello';
    ...
                'pack'      =>  q{  $str = pack("A10",$str);        },
                'sprintf'   =>  q{  $str = sprintf("%-10s",$str);   },
    });
    
  2. or download this
    Benchmark: timing 10000000 iterations of pack, sprintf...
          pack: 18 secs (16.86 usr  0.00 sys = 16.86 cpu)
       sprintf: 18 secs (17.36 usr  0.00 sys = 17.36 cpu)