use Benchmark; $s=($" x 1000)."test"; sub a { $_=$s;s/^ +//; } sub b { $_=$s;while(index($_, " ") == 0) { $_ = substr($_, 1) }} sub c { $_=$s; while (1) { $last = index($_, " ", $pos); $last > -1 and $pos = $last+1; $last == -1 and last; } substr($_, 0, $pos) = ""; } # c timethese(10000, {a=>\&a,b=>\&b,c=>\&c} );