substitution problems using perl
j proctor
jproctor at oit.umass.edu
Fri Nov 5 08:25:56 CST 1999
On the Jax.PM jacksonville-pm-list;
j proctor <jproctor at oit.umass.edu> wrote -
> I moved to Silicon Valley and got a job as a sys admin and Perl
> scripter at a web hosting company.
Cool. Congrats.
> P.S. Here's an interesting one: what if I wanted to save the matched
> number, and increment it by one?
> Something like:
> c:\>perl -pi.bak -e 's/^(\t\t9\d*)$/"$1++"/e' COMCITY.zone
s/^\t\t(9\d*)$/$1++/e should be closer (note the ()'s don't enclose the
\t's). I, like what's-his-name that also responded, am too lazy to go
test this myself. You actually have a slightly more complicated question;
if I were writing such a tool, I'd probably not try to run it in place
from the command line, and add some logic to update the date-stamp part of
the serial number, too.
And while I was at it, I'd make a point to switch to a 1999110521 format
(for example), because it's still obvious what's going on, and it won't
break when you want to update something 2 months from now (IIRC serial
numbers have to increase with each update).
j
The Jacksonville Perl Monger's Group is operated by -
Bill -Sneex- Jones ( sneex at usa.net ),
to whom send all praises, complaints, or comments...
More information about the Jacksonville-pm
mailing list