Chris wrote:
> 
> Before I re-invent the wheel...
> 
> I open a file for output but do not want to overwrite if it exists. It
> should be renamed with a serial number as an extension
> 
> for example
> filename test.txt
> 
> rename to
> test.001
> test.002
> test.003


You mean something like this:

my ( $file, $ext );
do  {
    $file = sprintf 'test.%03d', ++$ext;
    } while -e $file;

open OUT, "> $file" or die "Cannot open $file: $!";



John
-- 
use Perl;
program
fulfillment

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

Reply via email to