$x = '1234!' x 11000;; say length $x;; 55000 $t=time; substr( $x, 0, 50e3 ) =~ tr[!][\n]; printf "%.9f\n", time() - $t;; 0.000025034