CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
list all files in a dir?

 



ultimategamer2k
User

Mar 10, 2001, 9:14 PM

Post #1 of 2 (232 views)
list all files in a dir? Can't Post

what is the code to print all the names of files in a directory to a browser?

visit my web site at http://ultimategamer.cjb.net


parham_m_s
journeyman

Mar 11, 2001, 5:57 AM

Post #2 of 2 (225 views)
Re: list all files in a dir? [In reply to] Can't Post

try this code:


Code
#!/usr/bin/perl 

print "Content-type:text/html\n\n";

$directory = "PATH TO DIR";

opendir (DIR,$directory);
@files = readdir(DIR);
closedir (DIR);
foreach $file (@files) {
if ($file ne ".") {
if ($file ne "..") {
print "$file\n";
}
}
}

exit;

i just realized there was a double post of this :(

(This post was edited by parham_m_s on Mar 11, 2001, 5:00 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives