> -----Original Message-----
> From: Jorge Goncalvez [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, November 14, 2001 3:10 AM
> To: [EMAIL PROTECTED]
> Subject: RE:Perl & rename File 
> 
> 
> Hi,I have a perl tk application that create a file 
> c:/cygwin_syslog.txt.
> I have this file c:/cygwin_syslog.txt, How I can do to verify 
> if this file 
> exists at the init of my application, if it exists I would 
> rename it in 
> c:/cygwin_syslog.bck0, and recreate one with the same name ie 
> cygwin_syslog.txt 
> empty and ready to be appended.
> I do the same when i restarted my application, if 
> cygwin_syslog.txt already 
> exists  I rename it in cygwin_syslog.bck1 and every time I 
> restart my app It 
> would be rename till cygwin_syslog.bc9.
> How can I do this in perl .
> Thanks 

$file = 'cygwin_syslog';
unlink("$file.bck9");
rename("$file.bck$_", "$file.bck" . $_ + 1) for reverse((0..8));
rename("$file.txt", "$file.bck0");

Steps:
1. remove backup #9
2. rename 8->9, 7->8, and so on through 0->1
3. rename .txt -> .bck0

You don't really need to test for the existence of the files; if
they aren't there the rename's fail silently.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to