The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

File::RegexMatch - Module to help locate files using regular expressions.

SYNOPSIS

    #!/usr/bin/env perl -w

    use strict;
    use File::RegexMatch;

    foreach (File::RegexMatch->new(verbose => 1)->match(
        base_directory => "/home/user/public_html",
        match_pattern  => qr/(java|class)/,
        ignore_pattern => qr/(\.java|\.class)$/,
        include_hidden => 0
    )) {
        print $_->path() . "\n";
    }

DESCRIPTION

This module provides the functionality to traverses a directory tree and return an array of File::RegexMatch::File objects. Each file that is returned has a filename that matches the regular expression that is passed to the match subroutine.

METHODS

new

Instantiates and returns a new File::RegexMatch object. An optional argument for verbose can be passed to the constructor. Verbose property value is 0 (false) by default.

match

This method takes up to three parameter, base_directory , match_pattern and include_hidden .

The base_directory parameter defines the directory which the method should start traversing. An absolute or relative path can be used. The default value for this is $ENV{HOME} - the users home directory.

The match_pattern parameter is the regular expression that you wish to match file names against. The default value of this parameter is qr/.*/ .

The ignore_pattern parameter defines the regular expression that states which file names should be ignored. This is undefined by default.

The include_hidden parameter should be set to true if the method should include hidden files in its search. By default this is set to false (0).

SEE ALSO

File::RegexMatch::File

BUGS

Please report any bugs or feature requests to lloydg@cpan.org

AUTHOR

Lloyd Griffiths

COPYRIGHT

Copyright (c) 2011-2013 Lloyd Griffiths

This software is free software; you can redistribute it and/or modify it under the same terms as Perl itself.