1PPIx::Regexp::Token::MoUdsiefrieCro(n3t)ributed Perl DocPuPmIexn:t:aRteigoenxp::Token::Modifier(3)
2
3
4

NAME

6       PPIx::Regexp::Token::Modifier - Represent modifiers.
7

SYNOPSIS

9        use PPIx::Regexp::Dumper;
10        PPIx::Regexp::Dumper->new( 'qr{foo}smx' )
11            ->print();
12
13       The trailing "smx" will be represented by this class.
14
15       This class also represents the whole of things like "(?ismx)". But the
16       modifiers in something like "(?i:foo)" are represented by a
17       PPIx::Regexp::Token::GroupType::Modifier.
18

INHERITANCE

20       "PPIx::Regexp::Token::Modifier" is a PPIx::Regexp::Token.
21
22       "PPIx::Regexp::Token::Modifier" is the parent of
23       PPIx::Regexp::Token::GroupType::Modifier.
24

DESCRIPTION

26       This class represents modifier characters at the end of the regular
27       expression.  For example, in "qr{foo}smx" this class would represent
28       the terminal "smx".
29
30   The "a", "aa", "d", "l", and "u" modifiers
31       The "a", "aa", "d", "l", and "u" modifiers, introduced starting in Perl
32       5.13.6, are used to force either Unicode pattern semantics ("u"),
33       locale semantics ("l") default semantics ("d" the traditional Perl
34       semantics, which can also mean 'dual' since it means Unicode if the
35       string's UTF-8 bit is on, and locale if the UTF-8 bit is off), or
36       restricted default semantics ("a"). These are mutually exclusive, and
37       only one can be asserted at a time. Asserting any of these overrides
38       the inherited value of any of the others. The "asserted()" method
39       reports as asserted the last one it sees, or none of them if it has
40       seen none.
41
42       For example, given "PPIx::Regexp::Token::Modifier" $elem representing
43       the invalid regular expression fragment "(?dul)", "$elem->asserted( 'l'
44       )" would return true, but "$elem->asserted( 'u' )" would return false.
45       Note that "$elem->negated( 'u' )" would also return false, since "u" is
46       not explicitly negated.
47
48       If $elem represented regular expression fragment "(?i)",
49       "$elem->asserted( 'd' )" would return false, since even though "d"
50       represents the default behavior it is not explicitly asserted.
51
52   The caret ("^") modifier
53       Calling "^" a modifier is a bit of a misnomer. The "(?^...)"
54       construction was introduced in Perl 5.13.6, to prevent the inheritance
55       of modifiers. The documentation calls the caret a shorthand equivalent
56       for "d-imsx", and that it the way this class handles it.
57
58       For example, given "PPIx::Regexp::Token::Modifier" $elem representing
59       regular expression fragment "(?^i)", "$elem->asserted( 'd' )" would
60       return true, since in the absence of an explicit "l" or "u" this class
61       considers the "^" to explicitly assert "d".
62
63       Note that if this is retracted before Perl 5.14 is released, this
64       support will disappear. See "NOTICE" in PPIx::Regexp for some
65       explanation.
66

METHODS

68       This class provides the following public methods. Methods not
69       documented here are private, and unsupported in the sense that the
70       author reserves the right to change or remove them without notice.
71
72   asserts
73        $token->asserts( 'i' ) and print "token asserts i";
74        foreach ( $token->asserts() ) { print "token asserts $_\n" }
75
76       This method returns true if the token explicitly asserts the given
77       modifier. The example would return true for the modifier in "(?i:foo)",
78       but false for "(?-i:foo)".
79
80       If called without an argument, or with an undef argument, all modifiers
81       explicitly asserted by this token are returned.
82
83   match_semantics
84        my $sem = $token->match_semantics();
85        defined $sem or $sem = 'undefined';
86        print "This token has $sem match semantics\n";
87
88       This method returns the match semantics asserted by the token, as one
89       of the strings 'a', 'aa', 'd', 'l', or 'u'. If no explicit match
90       semantics are asserted, this method returns "undef".
91
92   modifiers
93        my %mods = $token->modifiers();
94
95       Returns all modifiers asserted or negated by this token, and the values
96       set (true for asserted, false for negated). If called in scalar
97       context, returns a reference to a hash containing the values.
98
99   negates
100        $token->negates( 'i' ) and print "token negates i\n";
101        foreach ( $token->negates() ) { print "token negates $_\n" }
102
103       This method returns true if the token explicitly negates the given
104       modifier. The example would return true for the modifier in
105       "(?-i:foo)", but false for "(?i:foo)".
106
107       If called without an argument, or with an undef argument, all modifiers
108       explicitly negated by this token are returned.
109

SUPPORT

111       Support is by the author. Please file bug reports at
112       <http://rt.cpan.org>, or in electronic mail to the author.
113

AUTHOR

115       Thomas R. Wyant, III wyant at cpan dot org
116
118       Copyright (C) 2009-2013 by Thomas R. Wyant, III
119
120       This program is free software; you can redistribute it and/or modify it
121       under the same terms as Perl 5.10.0. For more details, see the full
122       text of the licenses in the directory LICENSES.
123
124       This program is distributed in the hope that it will be useful, but
125       without any warranty; without even the implied warranty of
126       merchantability or fitness for a particular purpose.
127
128
129
130perl v5.16.3                      2014-06-10  PPIx::Regexp::Token::Modifier(3)
Impressum