加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Perl脚本:列出目录下所有的文件扩展名(后缀名)

发布时间:2020-12-16 00:32:55 所属栏目:大数据 来源:网络整理
导读:? #!/bin/perl # Extension_filename_lister v0.1 # List all extension filenames without duplicate in a directory. use strict; use warnings; use File::Find; my %extname_list; sub process_file { ??? my $cur_file = $_;? ??? # Ignore the directo
?

#!/bin/perl
# Extension_filename_lister v0.1
# List all extension filenames without duplicate in a directory.

use strict;
use warnings;
use File::Find;

my %extname_list;

sub process_file {
??? my $cur_file = $_;?

??? # Ignore the directories . and ..
??? if ($cur_file eq "." || $cur_file eq "..") {
??????? return;
??? }

??? (my $ext_name) = ($cur_file =~ /.(w+)$/);

??? if (defined ($ext_name)) {
??????? $extname_list{$ext_name} = "Yes";
??? }

#??? print $cur_file,"n";
#??? print $ext_name,"n";
}

my @DIRLIST = (".");?
find(&;process_file,@DIRLIST);

print "Extension filenames:n"; foreach my $item (keys %extname_list) { ??? print $item,"n"; }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读