in reply to Search patern within pattern in a single substitute command
is it possible to accomplish this in one s/// command?Yes, but it is hideously ugly, and you shouldn't do it this way (update... do it BrowserUk's way):
prints:use warnings; use strict; while (my $line = <DATA>){ chomp $line; $line =~ s/(.{5})(.{4})/$1 . $2 . ' ' . substr($2, 0, 1) . 'Y' . s +ubstr($2, 2, 2)/e; print $line . "\n"; } __DATA__ col1 col2 col3 col4 col5 1234 5678 9012 3456 7890
col1 col2 cYl2 col3 col4 col5 1234 5678 5Y78 9012 3456 7890
|
|---|