• 树状递归列出目录下面子目录和文件
#!/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. Sleep(0)的妙用

    在线程中,调用sleep(0)可以释放cpu时间,让线程马上重新回到就绪队列而非等待队列,sleep(0)释放当前线程所剩余的时间片(如果有剩余的话),这样可以让操作系统切换其他线程来执行,提升效率. ...

  2. 【16.56%】【codeforces 687B】Remainders Game

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. PHP中遍历关联数组的方法

    下面介绍PHP中遍历关联数组的三种方法:foreach <?php $sports = array( 'football' => 'good', 'swimming' => 'ver ...

  4. WPF安装打印机驱动后PrintDialog 执行打印事件

    原文:WPF安装打印机驱动后PrintDialog 执行打印事件 WPF可以很好的利用流文档来实现打印预览和PrintDialog 实现打印功能,但是我在这只是写了一个很简单的打印功能演示. Page ...

  5. QT 内存文件映射就是如此简单!

    QFile file(fileName); file.open(QIODevice::ReadWrite ); uchar* fpr = file.map(0, file.size());//映射文件 ...

  6. B&#233;zier curve

    Applications in computer graphics and computer-aided design (CAD) require the rapid generation of sm ...

  7. matlab 矢量化编程(三) —— 软阈值函数

    dj,k^=⎧⎩⎨⎪⎪dj,k−λ,dj,k≥λ0,otherwisedj,k+λ,dj,k≤−λ function y = soft(x, T) y = (x - abs(T) > 0) .* ...

  8. Python缺乏调查的陷阱 动态实例属性、引用、逃生

    --看到哪里.想到哪里,记到哪里 非常多时候.非常多人学python的时候,会忽略的东西非常多.大多数都盯着能"出货"即可,可是通常在读别人的代码的时候发现,看不懂...一方面是自 ...

  9. Visifire charts ToolBar

    <charts:Chart x:Name="ChartPat" Theme="Theme2" BorderBrush="Gray" P ...

  10. WCF学习目录

    WCF 基本 WCF概念 WCF配置文件详解 多个不同类对象传输思路 WCF 大文件传输配置 Uri ? & = 毫秒数据字符串转换为DateTime POST请求——HttpWebReque ...