How to exclude HTML extension

I use a script that list all recently updated files in directories. Actually
the script works fine but it list absolutely everything it founds, cgi, txt
etc.

I need it to list ONLY files ending with the extension .shtml

How can I modify the script?

I also would like to know how I can close the previous Q i asked, they were answered and there is no option available for me to give my points and unlocked the Q.


Thanks



++++++++++++++

Here it is:

# full path to the directory you want to view
$dir_path = "/www/web/mysite/directory/";

# full internet url that points to that directory
$internet_url_to_dir = "http://www.mysite.com/directory;

# if you wish to traverse subdirectories, make this value 1, otherwise make
it 0
$traverse_subdirectories = 1;

# only display the files updated in the last ?? days
# (set to 10000 if no time restriction desired)
$updates_boundary = 7; #days

###### YOU NEED NOT MODIFY ANYTHING BELOW THIS POINT ######

$| = 1; #no buffering of output
$add_path = "";

# remove / from end of paths if present
$dir_path =~ s/\/$//;
$internet_url_to_dir =~ s/\/$//;

print "Content-type: text/html\n\n<html><title>Directory listing of "
 . "$internet_url_to_dir</title><body bgcolor=white><h2>Directory listing of
"
 . "$internet_url_to_dir</h2>last modification is listed next to the
file<br><br>\n";

$sep = "";


GETDIR: {
 opendir(DIR,"$dir_path$sep$add_path")
  or print "<font color=red>can't open directory
$dir_path$sep$add_path</font><br>\n";
 push @files, map { $_ = "$add_path$_"; } grep !/^\.+/, readdir DIR;
 closedir(DIR);
 push @dirs, grep {-d "$dir_path/$_"} @files;



 @files = grep {-T "$dir_path/$_" and (-M "$dir_path/$_") <
$updates_boundary} @files;
 if ($traverse_subdirectories and scalar @dirs) {
  $add_path = (shift @dirs)."/";
  $sep = "/";
  redo GETDIR;
 }
}

foreach $file (sort { -M "$dir_path/$a" <=> -M "$dir_path/$b" } @files) {
 print "<a href='$internet_url_to_dir/$file'>$file</a> ",
  &formatTime((stat "$dir_path/$file")[9]),"<br>\n";
}

print "</body></html>\n";

sub formatTime {
 my ($min,$hour,$day,$mon,$year) = (localtime $_[0])[1..5];
 $mon++;
 $year %= 100;
 return "$mon/$day/$year $hour:".sprintf("%02d",$min);
}


wireframAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
grep /\.shtml$/, readdir DIR
0
wireframAuthor Commented:
grep /\.shtml$/, readdir DIR

result is the script doesn't read through all directories, stop after printing the 2 first lines:

Directory listing of
modification is listed next to the
file




0
wireframAuthor Commented:
grep /\.shtml$/, readdir DIR

result is the script doesn't read through all directories, stop after printing the 2 first lines:

Directory listing of
modification is listed next to the
file




0
ozoCommented:
You seem to looking for subdirectories when you
  push @dirs, grep {-d "$dir_path/$_"} @files;
and I'd imagine that most subdirectory names wouldn't end in .shtml,
so perhaps you want to exclude extensions at a different point?
You can do
  @files = grep {/\.shtml$/} @files;
when you want only files ending with the extension .shtml in @files
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wireframAuthor Commented:
Thanks a lot Ozo.

It was exactly the problem, the script couldn't read directories because of the extension!

Thanks again!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.