Install Perl 5.8.8
[msysgit.git] / mingw / html / ext / re / re.html
blobdca3fecec33cf4764a6b423eed8c3ff5ee82fb61
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>re - Perl pragma to alter regular expression behaviour</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;re - Perl pragma to alter regular expression behaviour</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#synopsis">SYNOPSIS</a></li>
24 <li><a href="#description">DESCRIPTION</a></li>
25 </ul>
26 <!-- INDEX END -->
28 <hr />
29 <p>
30 </p>
31 <h1><a name="name">NAME</a></h1>
32 <p>re - Perl pragma to alter regular expression behaviour</p>
33 <p>
34 </p>
35 <hr />
36 <h1><a name="synopsis">SYNOPSIS</a></h1>
37 <pre>
38 use re 'taint';
39 ($x) = ($^X =~ /^(.*)$/s); # $x is tainted here</pre>
40 <pre>
41 $pat = '(?{ $foo = 1 })';
42 use re 'eval';
43 /foo${pat}bar/; # won't fail (when not under -T switch)</pre>
44 <pre>
46 no re 'taint'; # the default
47 ($x) = ($^X =~ /^(.*)$/s); # $x is not tainted here</pre>
48 <pre>
49 no re 'eval'; # the default
50 /foo${pat}bar/; # disallowed (with or without -T switch)
51 }</pre>
52 <pre>
53 use re 'debug'; # NOT lexically scoped (as others are)
54 /^(.*)$/s; # output debugging info during
55 # compile and run time</pre>
56 <pre>
57 use re 'debugcolor'; # same as 'debug', but with colored output
58 ...</pre>
59 <p>(We use $^X in these examples because it's tainted by default.)</p>
60 <p>
61 </p>
62 <hr />
63 <h1><a name="description">DESCRIPTION</a></h1>
64 <p>When <code>use re 'taint'</code> is in effect, and a tainted string is the target
65 of a regex, the regex memories (or values returned by the m// operator
66 in list context) are tainted. This feature is useful when regex operations
67 on tainted data aren't meant to extract safe substrings, but to perform
68 other transformations.</p>
69 <p>When <code>use re 'eval'</code> is in effect, a regex is allowed to contain
70 <code>(?{ ... })</code> zero-width assertions even if regular expression contains
71 variable interpolation. That is normally disallowed, since it is a
72 potential security risk. Note that this pragma is ignored when the regular
73 expression is obtained from tainted data, i.e. evaluation is always
74 disallowed with tainted regular expressions. See <a href="file://C|\msysgit\mingw\html/pod/perlre.html#___code___">(?{ code }) in the perlre manpage</a>.</p>
75 <p>For the purpose of this pragma, interpolation of precompiled regular
76 expressions (i.e., the result of <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_qr_"><code>qr//</code></a>) is <em>not</em> considered variable
77 interpolation. Thus:</p>
78 <pre>
79 /foo${pat}bar/</pre>
80 <p><em>is</em> allowed if $pat is a precompiled regular expression, even
81 if $pat contains <code>(?{ ... })</code> assertions.</p>
82 <p>When <code>use re 'debug'</code> is in effect, perl emits debugging messages when
83 compiling and using regular expressions. The output is the same as that
84 obtained by running a <code>-DDEBUGGING</code>-enabled perl interpreter with the
85 <strong>-Dr</strong> switch. It may be quite voluminous depending on the complexity
86 of the match. Using <code>debugcolor</code> instead of <code>debug</code> enables a
87 form of output that can be used to get a colorful display on terminals
88 that understand termcap color sequences. Set <code>$ENV{PERL_RE_TC}</code> to a
89 comma-separated list of <code>termcap</code> properties to use for highlighting
90 strings on/off, pre-point part on/off.
91 See <a href="file://C|\msysgit\mingw\html/pod/perldebug.html#debugging_regular_expressions">Debugging regular expressions in the perldebug manpage</a> for additional info.</p>
92 <p>The directive <code>use re 'debug'</code> is <em>not lexically scoped</em>, as the
93 other directives are. It has both compile-time and run-time effects.</p>
94 <p>See <a href="file://C|\msysgit\mingw\html/pod/perlmodlib.html#pragmatic_modules">Pragmatic Modules in the perlmodlib manpage</a>.</p>
95 <table border="0" width="100%" cellspacing="0" cellpadding="3">
96 <tr><td class="block" style="background-color: #cccccc" valign="middle">
97 <big><strong><span class="block">&nbsp;re - Perl pragma to alter regular expression behaviour</span></strong></big>
98 </td></tr>
99 </table>
101 </body>
103 </html>