http://www.perlmonks.org?node_id=106033


in reply to substr and strings on the outside

Regex search and replace:

my $f = " "; $f =~ s/^(.{0,5}).{0,5}/${1}12345/;

The only problem is this regex doesn't pad extra spaces if your string is too short, but at least it still does the replacement.

elbieelbieelbie