zuppy
asked on
Directory file listing like dos "DIR *.html" clone
Hi,
I need to scan a directory (via CGI) to have all html files (the names) into an array (like dir *.html in DOS).
I've writed this piece of code but it seems not work.
Any idea?
#!/usr/bin/perl
open(STDERR,'>&STDOUT');
$| = 1;
print "Content-type: text/html\n\n";
& scan_files;
sub scan_files {
my (@files,$list);
#$dir will change by a data sent via cgi
$dir="/inetpub/wwwroot/gab bia/cgi-bi n/Annunci/ male_slave ";
opendir(dir,$dir);
@files=grep { /^\./ && -f "$dir/$_"} readdir(dir);
closedir (dir);
foreach $list (@files)
{
print $list;
print "\n";
}
}
#I'd like have the names into @files array
I need to scan a directory (via CGI) to have all html files (the names) into an array (like dir *.html in DOS).
I've writed this piece of code but it seems not work.
Any idea?
#!/usr/bin/perl
open(STDERR,'>&STDOUT');
$| = 1;
print "Content-type: text/html\n\n";
& scan_files;
sub scan_files {
my (@files,$list);
#$dir will change by a data sent via cgi
$dir="/inetpub/wwwroot/gab
opendir(dir,$dir);
@files=grep { /^\./ && -f "$dir/$_"} readdir(dir);
closedir (dir);
foreach $list (@files)
{
print $list;
print "\n";
}
}
#I'd like have the names into @files array
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
but please replay...so I can give them
Huh? You wrote please replay. What to replay, eh? :-)
ASKER
sorry, it was a "broswer reload" problem :)
Have you taken your points?
Have you taken your points?
Yeah, of course, thanks.
ASKER
So for you 30 points :)