NAME

Pitonyak::SafeGlob - Regular expressions and file specs for finding files and directories.


SYNOPSIS

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);


DESCRIPTION

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()
Note that this is written in such a manner that it can be inherited. Also note that it is written such that $obj2 = $obj1->new() is valid!

case_sensitive

case_sensitive([0|1])
Set the attribute if a parameter is present.

Return the state of the parameter.

copy

copy($object)
Make a copy of this object

$obj1-copy($obj2)> is the same as $obj1 = $obj2.

get_class_attribute

Remember that the call $obj->method(@parms) is the same as method($obj, @parms).

SafeGlob::get_class_attribute($attribute_name)
If there is only one paramter, the first parameter is assumed to be an attribute name and the default attribute value is returned.

$obj->get_class_attribute($attribute_name)
If there are two parameters, then the first parameter is assumed to be a SafeGlob object and the second parameter is assumed to be an attribute name. The attribute value for the object is returned.

$obj->get_class_attribute($attribute_name, $attribute_value)
If three parameters are given, then the first parameter is the object, the second parameter is used to set a new value for the attribute, and the third parameter is the attribute name, The attribute value is then returned.

glob_regex

glob_regex($path, [@regular_expressions])

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.

glob_regex_dirs

glob_regex_dirs($path, [@dir_regular_expressions])

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.

glob_regex_files

glob_regex_files($path, [@file_regular_expressions])

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.

glob_spec

glob_spec($path, [@regular_expressions])

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

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

recurse([0|1])
Set the attribute if a parameter is present.

Return the state of the parameter.

return_dirs

return_dirs([0|1])
Set the attribute if a parameter is present.

Return the state of the parameter.

return_files

return_files([0|1])
Set the attribute if a parameter is present.

Return the state of the parameter.


COPYRIGHT

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.


Modification History

March 13, 1998

Version 1.00 First release

September 10, 2002

Version 1.01 Changed internal documentation to POD documentation and support subdirectories