note
mrmick
One way is to get a list of the matching files in the directory, sorting them and adding to the digit. This example outputs last digit and the new filename to STDOUT to demonstrate:
<P>
(remember to use strict when programming)
<CODE>
$dir='path to directory';
opendir D, $dir or die "Cannot open directory $dir: $!\n";
while( defined (my $file = readdir(D)) ) {
if ($file =~ /\.dat$/){
push(@files,$file);
}
}
closedir D;
@files = sort @files;
@filename = split(/\./,$files[$#files]);
print $filename[0],"\n";
$filename = ($filename[0] + 1) . '.dat';
print $filename,"\n";
</CODE>
<P><center><font color=blue><B>Mick</B></font></center>
86954
86954