Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: incrementing the file

by oko1 (Deacon)
on Feb 22, 2012 at 05:02 UTC ( #955451=note: print w/ replies, xml ) Need Help??


in reply to Re^2: incrementing the file
in thread incrementing the file

You can try starting with a "templated" filename and increment it until you get past all the existing files:

my $fn = "output000"; $fn++ while -e $fn;

At that point, you'll have a filename that is just past the last one of that pattern. Minor caveat: make sure you have enough zeroes at the end of the template - or you'll start incrementing the characters. Yes, really.

ben@feynman:~$ perl -wle'$number = "one"; $number++ for 1..3624; print + $number' two

:)

-- 
I hate storms, but calms undermine my spirits.
 -- Bernard Moitessier, "The Long Way"


Comment on Re^3: incrementing the file
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://955451]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2015-07-04 10:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (59 votes), past polls