in reply to More efficient way of incrementing files?

You're matching .* for no good reason. And you're using a my $x in an if statement in a potentially dangerous way. I'd rewrite your code as:
for (reverse <file_name.*>) { my $old = $_; next unless s/\.([0-6])$/'.' . (1 + $1)/e; rename $old => $_; }
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.

_____________________________________________________
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
    Thank you japhy.

    What's funny is that I was attempting to use the /e modifier in a substitution with $1, except that I was using $1++, which of course dies a quick death

    Thanks again.