Board logo

标题: [分享]比较两种直接输出目录的方法 [打印本页]

作者: cnangel    时间: 2004-7-3 18:15     标题: [分享]比较两种直接输出目录的方法

一种函数输出
  1. #!/usr/bin/perl
  2. print "Content-type: text/html; charset = gb2312\n\n";
  3. opendir (DIR, ';.';);
  4. @filelist = readdir(DIR);
  5. close DIR;
  6. foreach (@filelist)
  7. {
  8. print $_ . "<br>\n";
  9. }
复制代码
另外一种模块输出
  1. &#35;!/usr/bin/perl  
  2. use strict;  
  3. use File::Find;  
  4. print "Content-type: text/html; charset = gb2312\n\n";
  5. my $path = ".";  
  6. find(\&process, $path);  
  7. sub process  
  8. {  
  9.    print $File::Find::dir, "$_<br>\n";  
  10. }
  11. exit;  
复制代码





欢迎光临 星星博客 (http://commerce.huhoo.net/) Powered by Discuz! 7.0.0