NAME
File::RegexMatch - Extension to help find files using regular expressions
SYNOPSIS
#!/usr/bin/env perl -w
use strict;
use File::RegexMatch;
my $regexmatch = File::RegexMatch->new(
verbose => 1,
);
my @ret = $regexmatch->match(
base_directory => "/home/user/public_html",
pattern => qr/\.pl$/,
include_hidden => 0,
);
foreach(@ret) { ... }
DESCRIPTION
This module provides a subroutine which traverses a directory tree and returns an array of files which match a given regular expression. The absolute path for each matching file is returned.
METHODS
new
$regexmatch = File::RegexMatch->new()
Creates a new File::RegexMatch object. An optional argument for verbose can be passed to it, default value is 0.
match
$regexmatch->match()
Takes three parameters, base_directory
, expression
and include_hidden
.
The base_directory
parameter defines the directory which is to be traversed. Either a relative or absolute path can be given.
The pattern
parameter is the regular expression that you want to match files against. This must be a regexp referece or the subroutine will complain.
The include_hidden
parameter lets the subroutine know if it should include hidden files (files beginning with a .) in the search. The value given should be a boolean, but the subroutine won't complain if it's not.
BUGS
Please report any bugs to frm-bugs[at]singletasker.co.uk
AUTHOR
Lloyd Griffiths lloydg[at]singletasker.co.uk
COPYRIGHT
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.