in reply to Using previous match in the same matching regexp
use warnings; use strict; my $string = '12 abcdefghijklmnopqrstuvwxyz'; $string =~ s/^(\d+) (.*)/substr $2, 0, $1/e; print "$string\n"; [download]
Prints:
abcdefghijkl [download]