man Text::Glob () - match globbing patterns against text
NAME
Text::Glob - match globbing patterns against text
SYNOPSIS
use Text::Glob qw( match_glob glob_to_regex );
print "matched\n" if match_glob( "foo.*", "foo.bar" );
# prints foo.bar and foo.baz my $regex = glob_to_regex( "foo.*" ); for ( qw( foo.bar foo.baz foo bar ) ) { print "matched: $_\n" if /$regex/; }
DESCRIPTION
Text::Glob implements glob(3) style matching that can be used to match against text, rather than fetching names from a filesystem. If you want to do full file globbing use the File::Glob module instead.
Routines
Returns the list of things which match the glob from the source list. Returns a compiled regex which is the equiavlent of the globbing pattern.
SYNTAX
The following metacharacters and rules are respected. CWa* matches CWa, CWaa, CWaaaa and many many more. CWa? matches CWaa, but not CWa, or CWaa
- Character sets/ranges
- CWexample.[ch] matches CWexample.c and CWexample.h CWdemo.[a-c] matches CWdemo.a, CWdemo.b, and CWdemo.c
- alternation
- CWexample.{foo,bar,baz} matches CWexample.foo, CWexample.bar, and CWexample.baz
- leading . must be explictly matched
- CW*.foo does not match CW.bar.foo. For this you must either specify the leading . in the glob pattern (CW.*.foo), or set CW$Text::Glob::strict_leading_dot to a false value while compiling the regex. CW*.foo does not match CWbar/baz.foo. For this you must either explicitly match the / in the glob (CW*/*.foo), or set CW$Text::Glob::strict_wildcard_slash to a false value with compiling the regex.
BUGS
The code uses qr// to produce compiled regexes, therefore this module requires perl version 5.005_03 or newer.
AUTHOR
Richard Clamp <richardc@unixbeard.net>
COPYRIGHT
Copyright (C) 2002 Richard Clamp. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.