in reply to More efficient way of incrementing files?
This kills a dozen birds with one stone. I do the substitution, instead of trying to match and then substituting. One of my regex red flags is the m/foo/ and s/foo/bar/ construct -- it's redundant. Also, I make the RHS (right-hand side) of the s/// code to be evaluated by using the /e modifier.for (reverse <file_name.*>) { my $old = $_; next unless s/\.([0-6])$/'.' . (1 + $1)/e; rename $old => $_; }
_____________________________________________________
Jeff japhy Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: More efficient way of incrementing files?
by the_slycer (Chaplain) on Jul 24, 2001 at 10:25 UTC |