• 树状递归列出目录下面子目录和文件
#!/usr/bin/perl
#List all files and sub-directories as tree
#Under current directory, or directory specified in command line use strict;
use warnings;
use File::Spec::Functions qw(catdir splitdir); my $curdir = @ARGV ? $ARGV[0] : '.';
unless (-d $curdir) { die "$curdir is not directory." } tree($curdir, 0);
exit 0; sub tree {
my ($dir, $depth)=@_;
my @directories = grep{$_} splitdir($dir);
my $short_name = $directories[-1];
my $prefix = '| ' x $depth;
print "$prefix$short_name/\n";
opendir (my $dh, $dir);
my @entries = grep{ !/^\./ } readdir($dh);
foreach my $entry (@entries){
#my $path = catdir($dir, $entry); #List full path of file
my $path=$entry; #List files
if (-f $path ){ print "$prefix|--$path\n";}
elsif (-d _) {tree ($path, $depth+1);}
else { }
}
}

Perl Scripts / 脚本的更多相关文章

  1. npm scripts 脚本基础指南

    什么是npm脚本? npm 允许在package.json文件里面,使用scripts字段定义脚本命令. 初始化package.json -> npm init -> 经历一系列的问答即可 ...

  2. 当然,perl等脚本服务器是一般默认安装了,你入侵了一台主机,总不能先装配 Java 环境然后再开干吧?

    转自:https://www.zhihu.com/question/20173592 当然,perl等脚本服务器是一般默认安装了,你入侵了一台主机,总不能先装配 Java 环境然后再开干吧?

  3. Vue.js源码解析-从scripts脚本看vue构建

    目录 1. scripts 脚本构建 1.1 dev 开发环境构建过程 1.1.1 配置文件代码 1.1.2 如何进行代码调试? 1.2 build 生产环境构建过程 1.2.1 scripts/bu ...

  4. [工具开发] Perl 爬虫脚本--从美国国家漏洞数据库抓取实时信息

    一.简介 美国国家漏洞数据库收集了操作系统,应用软件的大量漏洞信息,当有新的漏洞出现时,它也会及时发布出来. 由于信息量巨大,用户每次都需要到它的网站进行搜索,比较麻烦.如果能有个工具,每天自动分析它 ...

  5. 一个基于时间注入的perl小脚本

    use strict; use warnings; use LWP::Simple; my %table_and_leng; ;;$count++){ #print "Test Table: ...

  6. perl 脚本测试

      原文地址:  http://blog.csdn.net/johnny710vip/article/details/8905239   这是一篇关于perl脚本测试的总结性文章,其中提到了很多实用的 ...

  7. 这些年我们一起搞过的持续集成~Jenkins+Perl and Shell script

    这些年我们一起搞过的持续集成~Jenkins+Perl and Shell script ##转载注明出处:http://www.cnblogs.com/wade-xu/p/4378224.html ...

  8. Installing vSphere SDK for Perl

    Installing vSphere SDK for Perl 你可以安装vSphere SDK 在Linux 或者Microsoft Windows 系统,或者 部署 VSphere Managem ...

  9. orzdba_monitor.sh脚本使用

    1.orzdba_monitor.sh脚本使用 ./orzdba_monitor.sh 主要是用nohup同时在后台调用orzdba,启动下面三个命令 [root@node02 scripts]# p ...

随机推荐

  1. JQuery 多个checkbox 只选中一个

    <form id="common-form"> <input name="check1" type="checkbox"/ ...

  2. Max-Min Fairness带宽分配算法

    近期再写一个网络仿真器,里面參考了Max-MinFairness算法,这是一种比較理想.公平的带宽分配算法.其思路主要例如以下:首先是算法的准备,考察某一时刻的网络中全部的flow,因为每条flow都 ...

  3. Service熟人

    Service 为一体的四个分量间(剩余有Activity ,内容提供商,广播),它属于后台工作,能够在后台很长一段时间执行,他没有接口. 首先从使用方式上来说来说 他有两种使用方式: 1.启动式使用 ...

  4. hadoop 3.x 无法访问hdfs(50070,8088)的web界面

    1.启动hadoop.然后netstat -nltp|grep 50070,如果,没有找到进程,说明没有配置web界面的端口修改hdfs-site,xml中加上如下配置 再次启动后,netstat - ...

  5. SQLite的查询优化

    SQLite是个典型的嵌入式DBMS,它有很多优点,它是轻量级的,在编译之后很小,其中一个原因就是在查询优化方面比较简单,它只是运用索引机制来进行优化的,经过对SQLite的查询优化的分析以及对源代码 ...

  6. C# await 高级用法

    原文:C# await 高级用法 本文告诉大家 await 的高级用法,包括底层原理. 昨天看到太子写了一段代码,我开始觉得他修改了编译器,要不然下面的代码怎么可以编译通过 await "林 ...

  7. 允许Android对于飞行模拟器

    Android模拟器是公认的慢,并且不是一般的慢,即使在高性能的PC上,跟开发环境没关系,由于它就是慢.可是我们又必须使用模拟器,比方在測试Android不同版本号的兼容性时,或者在測试不同屏幕尺寸的 ...

  8. go语言刷leetcode - 14 Longest Common Prefix

    func longestCommonPrefix(strs []string) string { { return "" } { ] } ; ; idx++ { ; i < ...

  9. UVA - 10312 Expression Bracketing

    Description Problem A Expression Bracketing Input: standard input Output: standard output Time Limit ...

  10. Cocos2d-X之LUA注意事项

    「使用计时器」: 计时器函数原型:unsigned int scheduleScriptFunc(unsigned int handler, float interval, bool paused) ...