Hi all,
I reading the files in a dir and extracting a number out of the file names there. ie, I have a folder with filenames such as file1.htm, file2.htm.....file15.htm.....
I am using this to get the numbers off of the end of the filename:
Works great, except for 1 thing, it only reads the first number so the max that it sees is 9 Is there any way to chenge this to read everything from the end of file to the .htm or do I have to go about this another way?
Thanks in advance,
Jim
I reading the files in a dir and extracting a number out of the file names there. ie, I have a folder with filenames such as file1.htm, file2.htm.....file15.htm.....
I am using this to get the numbers off of the end of the filename:
Code:
sub ReadFolder {
opendir (FOLDER, $folder) or die "No path available.";
@filenames= readdir(FOLDER);
closedir(FOLDER);
foreach $file (@filenames) {
if ($file =~ /prints(\d).*/i)
{
# catch the number
$num = $1;
# if new num is largest yet,
# replace maxNum with current num
# do this for all files and you will have
# largest number in the files.
if ($num > $maxNum) { $maxNum = $num; }
}
}
Works great, except for 1 thing, it only reads the first number so the max that it sees is 9 Is there any way to chenge this to read everything from the end of file to the .htm or do I have to go about this another way?
Thanks in advance,
Jim