unique file names

L

LELAND PRINCE

Thanks, this group has been a big help.

I need to create a backup copy of a working file that changes everyday,
but I need to maintain a copy from each day.

Would like to create:
back1.txt
back2.txt
..
..
back56.txt

Is there a way to do this without a while loop and -e test?

Leland
 
J

John Bokma

LELAND said:
Thanks, this group has been a big help.

I need to create a backup copy of a working file that changes everyday,
but I need to maintain a copy from each day.

Would like to create:
back1.txt
back2.txt
.
.
back56.txt

Is there a way to do this without a while loop and -e test?

that can cause a race condition so be carefull.

just use a date like:

20030914.back.txt
 
T

Ted Hopp

Keep a separate file of the next available index. Open and lock it exclusive
before making the update. This will have the side benefit of avoiding
multi-thread problems. (That is, if you also modify the process(es) that
modify the working file to also ask for a lock).

LELAND PRINCE said:
Thanks, this group has been a big help.

I need to create a backup copy of a working file that changes everyday,
but I need to maintain a copy from each day.

Would like to create:
back1.txt
back2.txt
.
.
back56.txt

Is there a way to do this without a while loop and -e test?

Leland

Ted Hopp
(e-mail address removed)
 
J

Jürgen Exner

LELAND PRINCE wrote:

To create unique file names in general please see the advice in PerlFAQ
" How do I make a temporary file name?"
The last section describes how to create unique file names manually.
I need to create a backup copy of a working file that changes
everyday, but I need to maintain a copy from each day.

Would like to create:
back1.txt
back2.txt
.
.
back56.txt

Is there a way to do this without a while loop and -e test?

Just read the directory, pick the (alphabetically) largest file name, and
add 1.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top