Hello!
I am using the following PERL code to display the contents of a sub-directory on my server:
sub doit {
opendir(DIRHANDLE,"/home/username/public_html/$DirName");
@filenames = ( sort readdir(DIRHANDLE) );
foreach $dirfile (@filenames) {
print "<b><a href='/$DirName/$dirfile' target='new'>$dirfile</a></b><br><br>";
}
}
That code simply opens a directory and spits out the contents (files and sub directories in alphabetical order) -
I was wondering how I could:
1. Get perl to recognize the difference between a file and a sub-directory
2. Get perl to recognize the different file extensions.. I would like to display .html files in green, .jpg files in blue and so on..
Or maybe someone can point me to a tutorial that will help with this type of issue???