所需阅读权限 1
[分享]比较两种直接输出目录的方法
一种函数输出- #!/usr/bin/perl
- print "Content-type: text/html; charset = gb2312\n\n";
- opendir (DIR, ';.';);
- @filelist = readdir(DIR);
- close DIR;
- foreach (@filelist)
- {
- print $_ . "<br>\n";
- }
复制代码 另外一种模块输出- #!/usr/bin/perl
-
- use strict;
- use File::Find;
- print "Content-type: text/html; charset = gb2312\n\n";
- my $path = ".";
- find(\&process, $path);
- sub process
- {
- print $File::Find::dir, "$_<br>\n";
- }
- exit;
复制代码 |