7 re - Perl pragma to alter regular expression behaviour
12 ($x) = ($^X =~ /^(.*)$/s); # $x is tainted here
14 $pat = '(?{ $foo = 1 })';
16 /foo${pat}bar/; # won't fail (when not under -T switch)
19 no re 'taint'; # the default
20 ($x) = ($^X =~ /^(.*)$/s); # $x is not tainted here
22 no re 'eval'; # the default
23 /foo${pat}bar/; # disallowed (with or without -T switch)
27 /^(.*)$/s; # output debugging info
28 # during compile and run time
30 (We use $^X in these examples because it's tainted by default.)
34 When C<use re 'taint'> is in effect, and a tainted string is the target
35 of a regex, the regex memories (or values returned by the m// operator
36 in list context) are tainted. This feature is useful when regex operations
37 on tainted data aren't meant to extract safe substrings, but to perform
38 other transformations.
40 When C<use re 'eval'> is in effect, a regex is allowed to contain
41 C<(?{ ... })> zero-width assertions even if regular expression contains
42 variable interpolation. That is normally disallowed, since it is a
43 potential security risk. Note that this pragma is ignored when the regular
44 expression is obtained from tainted data, i.e. evaluation is always
45 disallowed with tainted regular expresssions. See L<perlre/(?{ code })>.
47 For the purpose of this pragma, interpolation of preexisting regular
48 expressions is I<not> considered a variable interpolation, thus
52 I<is> allowed if $pat is a preexisting regular expressions, even
53 if $pat contains C<(?{ ... })> assertions.
55 When C<use re 'debug'> is in effect, perl emits debugging messages when
56 compiling and using regular expressions. The output is the same as that
57 obtained by running a C<-DDEBUGGING>-enabled perl interpreter with the
58 B<-Dr> switch. It may be quite voluminous depending on the complexity
60 See L<perldebug/"Debugging regular expressions"> for additional info.
62 I<The directive C<use re 'debug'> is not lexically scoped.> It has
63 both compile-time and run-time effects.
65 See L<perlmodlib/Pragmatic Modules>.
79 Carp::carp("Useless use of \"re\" pragma");
85 @ISA = ('DynaLoader');
89 uninstall() unless $on;
92 $bits |= $bitmask{$s} || 0;