I think it adds legibility to make it a different step
I totally agree, in the general case. In this specific case, however, the first substitution — explicitly stripping off trailing whitespace — is in fact not needed at all, because the second substitution does that anyway:
18:14 >perl -wE "my $s = '2. Kim Washington '; $s =~ s/^\d+\.\s+( +\w+\s+\w).*$/$1. /; say qq['$s'];" 'Kim W. ' 18:14 >
Note also that in a substitution, only the left-hand part is a regex; the right-hand part is just an (interpolated) string, so the . doesn’t need to be escaped.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^3: combining lists along with a regex
by Athanasius
in thread combining lists along with a regex
by Aldebaran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |