list all files in directory


/ Published in: Perl
Save to your folder(s)

list all files in dir


Copy this code and paste it in your HTML
  1. opendir(IMD, $dirtoget) || die("Cannot open directory");
  2. @thefiles= readdir(IMD);
  3. closedir(IMD);
  4.  
  5. print "Content-type: text/html\n\n";
  6. print "<html><body>";
  7.  
  8. foreach $f (@thefiles)
  9. {
  10. unless ( ($f eq ".") || ($f eq "..") )
  11. {
  12. print "$f<br />";
  13. }
  14. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.