use strict; use CGI qw( :all ); my $user_agent = user_agent(); my $html_redirection = 'http://127.0.0.1/index.htm'; if ($user_agent =~ m#libwww-perl/#) { # it's a perl bot - probably ppm, so return a # compatible directory listing print_dir_listing(); } else { # it's probably a regular browser, redirect... print redirect(-uri => $html_redirection); } sub print_dir_listing { # Get the current directory, (cwd doesn't necessarily work in IIS) (my $cwd = $0) =~ s[\\][/]g; $cwd =~ s[/([^/]*)$][]; print header({-type => "text/plain"}); opendir FOLDER, $cwd or die "I don't have permission $!"; print a({-href => $_}, $_ ), "\n" for grep { /\.ppd$/ } readdir FOLDER; closedir FOLDER; }