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       match_glob( $glob, @things_to_test )
26           Returns the list of things which match the glob from the source
27           list.
28
29       glob_to_regex( $glob )
30           Returns a compiled regex which is the equiavlent of the globbing
31           pattern.
32
33       glob_to_regex_string( $glob )
34           Returns a regex string which is the equiavlent of the globbing
35           pattern.
36

SYNTAX

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

BUGS

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

AUTHOR

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

SEE ALSO

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