- Impact
- 6
This little snippet will print out a link to each file in the directory you specify as the $dirpath
Code:
#!/usr/bin/perl -w
#SIMPLE LINK CREATOR
use CGI::Carp qw(fatalsToBrowser);
#the server path to the directory with the files
my $dirpath = '/path/to/directory';
opendir DIR, $dirpath || die $!;
my @directory = readdir DIR;
closedir DIR;
print "Content-type: text/htmlnn";
foreach my $file (@directory) {
my $links = qq~<a href="$file">$file</a><br><br>n~;
print $links;
}