1Shellish(3)           User Contributed Perl Documentation          Shellish(3)
2
3
4

NAME

6       Regexp::Shellish - Shell-like regular expressions
7

SYNOPSIS

9          use Regexp::Shellish qw( :all ) ;
10
11          $re = compile_shellish( 'a/c*d' ) ;
12
13          ## This next one's like 'a*d' except that it'll
14          ## match 'a/d'.
15          $re = compile_shellish( 'a**d' ) ;
16
17          ## And here '**' won't match 'a/d', but behaves
18          ## like 'a*d', except for the possibility of high
19          ## cpu time consumption.
20          $re = compile_shellish( 'a**d', { star_star => 0 } ) ;
21
22          ## The next two result in identical $re1 and $re2.
23          ## The second is a noop so that Regexp references can
24          ## be easily accomodated.
25          $re1 = compile_shellish( 'a{b,c}d' ) ;
26          $re2 = compile_shellish( qr/\A(?:a(?:b⎪c)d)\Z/ ) ;
27
28          @matches = shellish_glob( $re, @possibilities ) ;
29

DESCRIPTION

31       Provides shell-like regular expressions.  The wildcards provided are
32       "?", "*" and "**", where "**" is like "*" but matches "/".  See "com‐
33       pile_shellish" for details.
34
35       Case sensitivity and constructs like <**>, "(a*b)", and "{a,b,c}" can
36       be disabled.
37
38       compile_shellish
39           Compiles a string containing a 'shellish' regular expression,
40           returning a Regexp reference.  Regexp references passed in are
41           passed through unmolested.
42
43           Here are the transformation rules from shellish expression terms to
44           perl regular expression terms:
45
46              Shellish  Perl RE
47              ========  =======
48              *         [^/]*
49              ?         .
50              **        .*               ## unless { star_star   => 0 }
51              ...       .*               ## unless { dot_dot_dot => 0 }
52
53              (         (                ## unless { parens => 0 }
54              )         )                ## unless { parens => 0 }
55
56              {a,b,c}   (?:a⎪b⎪c)        ## unless { braces => 0 }
57
58              \a        a                ## These are de-escaped and
59              \*        \*               ## passed to quotemeta()
60
61           The wildcards treat newlines as normal characters.
62
63           Parens group in to $1..$n, since they are passed through unmolested
64           (unless option parens => 0 is passed).  This is useless when using
65           glob_shellish(), though.
66
67           The final parameter can be a hash reference containing options:
68
69              compile_shellish(
70                 '**',
71                 {
72                    anchors        => 0,   ## Doesn't put ^ and $ around the
73                                           ## resulting regexp
74                    case_sensitive => 0,   ## Make case insensitive
75                    dot_dot_dot    => 0,   ## '...' is now just three '.' chars
76                    star_star      => 0,   ## '**' is now two '*' wildcards
77                    parens         => 0,   ## '(', ')' are now regular chars
78                    braces         => 0,   ## '{', '}' are now regular chars
79                 }
80              ) ;
81
82           No option affects Regexps passed through.
83
84       shellish_glob
85           Pass a regular expression and a list of possible values, get back a
86           list of matching values.
87
88              my @matches = shellish_glob( '*/*', @possibilities ) ;
89              my @matches = shellish_glob( '*/*', @possibilities, \%options ) ;
90

AUTHOR

92       Barrie Slaymaker <barries@slaysys.com>
93
94
95
96perl v5.8.8                       2002-01-24                       Shellish(3)
Impressum