NAME
Dir::ListFilesRecursive - Static functions to find files in directories.
SYNOPSIS
# imports all functions
use Dir::ListFilesRecursive ':all';
# imports only one function
use Dir::ListFilesRecursive qw( list_files_recursive );
use Data::Dumper;
print Dumper( list_files_recursive('/etc') );
use Data::Dumper;
print Dumper( list_files_recursive('/etc', only_folders => 1) );
# shows only subfolders of /etc
DESCRIPTION
This class provides static functions which can be imported to the namespace of the current class. The functions lists the content of directories.
With options you can filter the files for specific criteria, like no hidden files, etc.
REQUIRES
METHODS
list_files_flat
my @array | \@arrayref = list_files_flat($path, %options);
List the files of a directory with full path.
print list_files_flat('/etc');
# may return files like:
# /etc/hosts
# /etc/passwd
It does not return directory names. (that means 'flat'), only the files of given directory.
You can set key value pairs to use further options. Please see chapter 'options'.
It returns an array or arrayref, depending on context.
list_files_no_path
my @array | \@arrayref = list_files_no_path($path, %options);
List the files of a directory without the path.
print list_files_no_path('/etc');
# may return files like:
# hosts
# passwd
It does not return directory names.
You can set key value pairs to use further options. Please see chapter 'options'.
It returns an array or arrayref, depending on context.
list_files_recursive
my @array | \@arrayref = list_files_recursive($path, %options);
List the files of a directory and subdirctories with full path.
print list_files_recursive('/etc');
# may return files like:
# /etc/hosts
# /etc/passwd
# /etc/apache/httpd.conf
You can set key value pairs to use further options. Please see chapter 'options'.
It returns an array or arrayref, depending on context.
Options
For some functions, you can set options like the only_folders in the SYNOPSIS's example. You can use the following options: As options you can set these flags:
only_folders => 1,
only_files => 1,
no_directories => 1,
no_folders => 1,
no_hidden_files => 1,
extension => 'string',
no_path => 1,
You can also use various aliases:
only_folders: only_folder, only_dir, only_dirs, only_directories, no_files
no_directories: no_dir, no_dirs, no_folder, no_folders
no_hidden_files: no_hidden
extension: ext
Not implemented so far: regular expression match, file age and other attributes.
AUTHOR
Andreas Hernitscheck ahernit(AT)cpan.org
LICENSE
You can redistribute it and/or modify it under the conditions of LGPL.