File: list_the_contents_of_a_directory_recursively.pl

package info (click to toggle)
libfile-util-perl 4.132140-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 792 kB
  • ctags: 155
  • sloc: perl: 3,874; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 560 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# ABSTRACT: List the contents of a directory and all its subdirectories (recursive)

use strict;
use warnings;
use File::Util qw( NL );

my $ftl = File::Util->new();

my $dir = '/tmp'; # in this example, this file must already exist

# option --no-fsdots excludes "." and ".." from the list
my @dirs_and_files = $f->list_dir( $dir, '--recurse' );

# The NL constant below will be the apropriate newline character sequence
# for your operating system... "\n" or "\r\n"

# print out the list of files, each on its own line
print join NL, @dirs_and_files;

exit;