1Text::Glob(3)         User Contributed Perl Documentation        Text::Glob(3)
2
3
4

NAME

6       Text::Glob - match globbing patterns against text
7

SYNOPSIS

9        use Text::Glob qw( match_glob glob_to_regex );
10
11        print "matched\n" if match_glob( "foo.*", "foo.bar" );
12
13        # prints foo.bar and foo.baz
14        my $regex = glob_to_regex( "foo.*" );
15        for ( qw( foo.bar foo.baz foo bar ) ) {
16            print "matched: $_\n" if /$regex/;
17        }
18

DESCRIPTION

20       Text::Glob implements glob(3) style matching that can be used to match
21       against text, rather than fetching names from a filesystem.  If you
22       want to do full file globbing use the File::Glob module instead.
23
24       Routines
25
26       match_glob( $glob, @things_to_test )
27           Returns the list of things which match the glob from the source
28           list.
29
30       glob_to_regex( $glob )
31           Returns a compiled regex which is the equiavlent of the globbing
32           pattern.
33
34       glob_to_regex_string( $glob )
35           Returns a regex string which is the equiavlent of the globbing pat‐
36           tern.
37

SYNTAX

39       The following metacharacters and rules are respected.
40
41       "*" - match zero or more characters
42           "a*" matches "a", "aa", "aaaa" and many many more.
43
44       "?" - match exactly one character
45           "a?" matches "aa", but not "a", or "aa"
46
47       Character sets/ranges
48           "example.[ch]" matches "example.c" and "example.h"
49
50           "demo.[a-c]" matches "demo.a", "demo.b", and "demo.c"
51
52       alternation
53           "example.{foo,bar,baz}" matches "example.foo", "example.bar", and
54           "example.baz"
55
56       leading . must be explictly matched
57           "*.foo" does not match ".bar.foo".  For this you must either spec‐
58           ify the leading . in the glob pattern (".*.foo"), or set
59           $Text::Glob::strict_leading_dot to a false value while compiling
60           the regex.
61
62       "*" and "?" do not match /
63           "*.foo" does not match "bar/baz.foo".  For this you must either
64           explicitly match the / in the glob ("*/*.foo"), or set
65           $Text::Glob::strict_wildcard_slash to a false value with compiling
66           the regex.
67

BUGS

69       The code uses qr// to produce compiled regexes, therefore this module
70       requires perl version 5.005_03 or newer.
71

AUTHOR

73       Richard Clamp <richardc@unixbeard.net>
74
76       Copyright (C) 2002, 2003, 2006, 2007 Richard Clamp.  All Rights
77       Reserved.
78
79       This module is free software; you can redistribute it and/or modify it
80       under the same terms as Perl itself.
81

SEE ALSO

83       File::Glob, glob(3)
84
85
86
87perl v5.8.8                       2007-05-02                     Text::Glob(3)
Impressum