Chinaunix首页 | 论坛 | 博客
  • 博客访问: 359110
  • 博文数量: 35
  • 博客积分: 2176
  • 博客等级: 大尉
  • 技术积分: 797
  • 用 户 组: 普通用户
  • 注册时间: 2006-08-13 14:03
文章分类

全部博文(35)

文章存档

2012年(9)

2009年(14)

2008年(12)

我的朋友

分类:

2009-06-16 16:59:47

#!/usr/bin/perl

use strict;
use warnings;

my $dir = "c:\\testfile";
$dir =~ s/\\/\//g;
process_dir($dir);

sub process_dir {
    my $dir = shift;
    opendir my $dh, $dir or die "Can't open directory $dir: $!\n";
    while (my $exist = readdir $dh) {
        next if $exist eq '.' or $exist eq '..';
        $exist = "$dir/$exist";
        if ( -f $exist) {
            my $path = $exist;
            $path =~ s/^.\///;
#            $path =~ s/.*\/(.*)$/g;

            print "directory: $dir, file: $path\n";
        } elsif (-d $exist) {
            process_dir($exist);
        }
    }
    closedir $dh;
}

阅读(838) | 评论(0) | 转发(0) |
0

上一篇:自动启动windows服务

下一篇:PERL模拟飞鸽

给主人留下些什么吧!~~