c:\@Work\Perl\monks>perl -wMstrict -le "my $template = 'all the %3$s %1$s %2$s'; my $extract = 'all at sea in ships'; ;; if ($extract =~ m{ \A all \s+ (\w+) \s+ (\w+) \s+ in \s+ (\w+) \z }xms) { my $string = sprintf $template, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13; print qq{>$string<}; } " >all the ships at sea<