Pitonyak::SafeGlob - Regular expressions and file specs for finding files and directories.
File and directory scanning based on regular expressions.
use Pitonyak::SafeGlob
my $case_sensitive = 1; my $include_files = 1; my $include_dirs = 0; my $recurse_dirs = 1; my @full_specs = ('c:/*.txt', '/usr/home/andy/*.txt'); my @file_specs = ('*.txt, *.MSG'); my @file_regs = ('.*\.txt, .*\.MSG'); my @files; @files = glob_spec_from_path($case_sensitive, $include_dirs, $include_files, $recurse_dirs, @full_specs); @files = glob_spec($case_sensitive, $include_dirs, $include_files, 'c:/', @file_specs); @files = glob_regex($case_sensitive, $include_dirs, $include_files, 'c:/', @file_regs);
There was a time when glob()
returned an empty list if there were too many files in a directory.
This module avoids this problem.
In the following routines, if the $use_case
parameter evaluates to true,
then matching will be done in a case sensitive manner. Matches are not
case sensitive otherwise.
In the following routines, if the $include_files
parameter evaluates to true,
then files that match will be returned.
In the following routines, if the $include_dirs
parameter evaluates to true,
then directories that match will be returned.
new()
new()
is valid!
case_sensitive([0|1])
Return the state of the parameter.
copy($object)
$obj1-
copy($obj2)> is the same as $obj1 = $obj2
.
Remember that the call $obj->method(@parms)
is the same as
method($obj, @parms)
.
get_class_attribute($attribute_name)
SafeGlob
object and the second parameter is
assumed to be an attribute name.
The attribute value for the object is returned.
All regular expressions are assumed to follow the path. This returns the files and/or directories that match the regular expression in the given path. The directory tree is recursed if the recursion flag is set.
All regular expressions are assumed to follow the path. This returns the directories that match the regular expression in the given path. Recursion is done if the recurse parameter is set.
All regular expressions are assumed to follow the path. This returns the files that match the regular expression in the given path. Recursion is done if the recurse parameter is set.
All file specs are assumed to follow the path. The file specs are turned into regular expressions and then glob_regex is called. This returns the files that match the file specification in the given path.
glob_spec_from_path([@file_specs_with_dirs])
This assumes that it is given a list of file specs where the file specs contain leading directory entries. The file spec and path are separated using File::Basename::fileparse() and then glob_spec is called.
recurse([0|1])
Return the state of the parameter.
return_dirs([0|1])
Return the state of the parameter.
return_files([0|1])
Return the state of the parameter.
Copyright 1998-2002, Andrew Pitonyak (perlboy@pitonyak.org)
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Version 1.00 First release
Version 1.01 Changed internal documentation to POD documentation and support subdirectories