点击(此处)折叠或打开
- #!/usr/bin/perl -w
- # name: total.pl
- # 统计目录下文件的数量、
- # 来源: Lover的工具小屋
- # author: Lover
- use strict;
- my $dir = shift || $ENV{'HOME'};
- my $total = 0;
- my $file;
- opendir DIR,$dir;
- while ( $file = readdir DIR){
- next if $file eq '.' || $file eq '..';
- $total += 1;
- }
- print("$total \n");
- closedir DIR;