• 树状递归列出目录下面子目录和文件
#!/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. WPF入门(三)->两个几何图形合并(CombinedGeometry)

    原文:WPF入门(三)->两个几何图形合并(CombinedGeometry) 在WPF中,提供了一个CombinedGeometry对象可以使两个几何图形合并产生效果 CombinedGeom ...

  2. hbase 2.0.2 分布式安装配置/jar包替换

    环境 zk: 3.4.10 hadoop 2.7.7 jdk8 hbase 2.0.2 三台已安装配置好的hadoop002,hadoop003,hadoop004 1.上传并解压hbase-2.1. ...

  3. lucene 7.x 查询

    @Test public void indexSearch() throws IOException, ParseException { //Termquery:精确string查询 // Query ...

  4. An HTTP & HTTP/2 client for Android and Java applications OkHttp

    HTTP is the way modern applications network. It’s how we exchange data & media. Doing HTTP effic ...

  5. 把搜狗输入法词库导入Google拼音输入法

    为PC端Google拼音输入法增加词库 为什么折腾词库 都在说百度.讯飞等输入法上传用户词库,为了安全建议大家使用google输入法之类,话说回来,要想使用智能联想功能是不是就得把你输入习惯放在他的里 ...

  6. uva 11552 Fewest Flops 线性dp

    // uva 11552 Fewest Flops // // 二维线性dp // // 首先,在该块必须是相同的来信.首先记录每块有很多种书 // 称为是counts[i]; // // 订购f[i ...

  7. C# 7.0 使用下划线忽略使用的变量

    原文:C# 7.0 使用下划线忽略使用的变量 版权声明:博客已迁移到 http://lindexi.gitee.io 欢迎访问.如果当前博客图片看不到,请到 http://lindexi.gitee. ...

  8. JIL 编译与 AOT 编译

    JIT:Just-in-time compilation,即时编译:AOT:Ahead-of-time compilation,事前编译. JVM即时编译(JIT) 1. 动态编译与静态编译 动态编译 ...

  9. Android GPS获取当前位置信息

    package com.example.gpstest; import org.apache.http.util.LangUtils; import android.content.Context; ...

  10. quartz2.x源码分析——启动过程

    title: quartz2.x源码分析--启动过程 date: 2017-04-13 14:59:01 categories: quartz tags: [quartz, 源码分析] --- 先简单 ...