Link to home
Start Free TrialLog in
Avatar of zuppy
zuppyFlag for Italy

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/gabbia/cgi-bin/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
ASKER CERTIFIED SOLUTION
Avatar of Mindo
Mindo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zuppy

ASKER

I've founded error...but your solution runs nice too...
So for you 30 points :)
Avatar of zuppy

ASKER

but please replay...so I can give them
Avatar of Mindo
Mindo

Huh? You wrote please replay. What to replay, eh? :-)
Avatar of zuppy

ASKER

sorry, it was a "broswer reload" problem :)
Have you taken your points?
Yeah, of course, thanks.