May not have hit your inbox yet... 0.056398 s/\s(?=\s*\S)/0/og 0.254457 while (s/\s(?=(\d|\.))/0/ {) 0.094268 s/^(\s+)(?=\d)/'0'x(length $1)/e 0.026934 (see below) Strip front space, take length diff, replace with n x "0" 0.095046 s/^(\s+)/sprintf "%s", q[0]x length($1)/eg 0.086842 s/ (?=.*\d)/0/g
Surprisingly, the more manual process is the fastest. This latest positive lookahead is a bit slower than the first one, I'm not sure why. ------------------ ($trimmed_string = $_) =~ s/^ *//; # remove leading spaces $transformed_string = ('0' x ((length $_) - length $trimmed_string)) . $trimmed_string; _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs