R
Ravi Parimi
Hi,
I am trying to print the list of files(excluding directories) in a
directory with a Perl/CGI script:
#!/usr/bin/perl -w
print "Content-type:text/html\n\n";
print "<pre>\n";
opendir DH,"/var/www/cgi-bin/results" or die "$!";
foreach my $ls (readdir DH) {
next if -d $ls;
print "$ls\n";
}
print "</pre>\n";
The above script gives the correct output(i.e. does not print directories)
when I run it from the command line. However, when run as a CGI, it even
prints the directory names as files. Is this normal behaviour? Any help is
appreciated.
Thanks,
--ravi
I am trying to print the list of files(excluding directories) in a
directory with a Perl/CGI script:
#!/usr/bin/perl -w
print "Content-type:text/html\n\n";
print "<pre>\n";
opendir DH,"/var/www/cgi-bin/results" or die "$!";
foreach my $ls (readdir DH) {
next if -d $ls;
print "$ls\n";
}
print "</pre>\n";
The above script gives the correct output(i.e. does not print directories)
when I run it from the command line. However, when run as a CGI, it even
prints the directory names as files. Is this normal behaviour? Any help is
appreciated.
Thanks,
--ravi