1PPIx::Regexp::Util(3) User Contributed Perl DocumentationPPIx::Regexp::Util(3)
2
3
4
6 PPIx::Regexp::Util - Utility functions for PPIx::Regexp;
7
9 use PPIx::Regexp::Util qw{ __instance };
10 .
11 .
12 .
13 __instance( $foo, 'Bar' )
14 or die '$foo is not a Bar';
15
17 This module contains utility functions for PPIx::Regexp which it is
18 convenient to centralize.
19
20 Double-underscore subroutines are private to the "PPIx-Regexp" package.
21 Their documentation is provided for the author's convenience only, and
22 they are subject to change without notice. Caveat user.
23
24 This module exports nothing by default.
25
27 This module can export the following subroutines:
28
29 is_ppi_regexp_element
30 is_ppi_regexp_element( $elem )
31 and print "$elem is a regexp of some sort\n";
32
33 This subroutine is public and supported.
34
35 This subroutine takes as its argument a PPI::Element. It returns a true
36 value if the argument represents a regular expression of some sort, and
37 a false value otherwise.
38
39 __instance
40 __instance( $foo, 'Bar' )
41 and print '$foo isa Bar', "\n";
42
43 This subroutine is private to the "PPIx-Regexp" package.
44
45 This subroutine returns true if its first argument is an instance of
46 the class specified by its second argument. Unlike "UNIVERSAL::isa",
47 the result is always false unless the first argument is a reference.
48
49 __is_ppi_regexp_element
50 __is_ppi_regexp_element( $elem )
51 and print "$elem is a regexp of some sort\n";
52
53 This subroutine is private to the "PPIx-Regexp" package.
54
55 This is a synonym for is_ppi_regexp_element(), and is deprecated in
56 favor of it. If called, it will complain via Carp::cluck() and then
57 "goto &is_ppi_regexp_element".
58
59 __merge_perl_requirements
60 This subroutine is private to the "PPIx-Regexp" package.
61
62 This subroutine merges perl requirements as returned by the various
63 "__perl_requirements()" methods.
64
65 __ns_can
66 This subroutine is private to the "PPIx-Regexp" package.
67
68 This method is analogous to can(), but returns a reference to the code
69 only if it is actually implemented by the invoking name space.
70
71 __post_rebless_error
72 This method is private to the "PPIx-Regexp" package. The intended use
73 is to alias it to "__PPIX_ELEM__post_reblessing()".
74
75 It takes arguments as name/value pairs. Argument "{error}" is the error
76 message; if it is omitted you get a warning with stack trace. Argument
77 "{explanation}" defaults to "{error}".
78
79 It returns the number of errors to add to the parse.
80
81 raw_width
82 This public method returns the minimum and maximum width matched by the
83 element before taking into account such details as what the element
84 actually is and how it is quantified.
85
86 This implementation is appropriate to things that match exactly one
87 character -- i.e. it returns "( 1, 1 )".
88
89 __to_ordinal_en
90 This subroutine is private to the "PPIx-Regexp" package.
91
92 This subroutine takes as its argument an integer and returns a string
93 representing its ordinal in English. For example
94
95 say __to_ordinal_en( 17 );
96 # 17th
97
98 width
99 my ( $min_wid, $max_wid ) = $self->width();
100
101 This public method (well, mixin) returns the minimum and maximum width
102 of the text matched by the element.
103
104 Elements which import this method must also implement a raw_width()
105 method which returns the unquantified width of the element.
106
108 The following export tags are defined by this module. All are private
109 to the "PPIx-Regexp" package unless otherwise documented.
110
111 all
112 This tag exports everything exportable by this module.
113
114 width_one
115 This tag is appropriate to an element which, when unquantified, matches
116 exactly one character. It exports raw_width() and width().
117
119 Params::Util, which I recommend, but in the case of "PPIx::Regexp" I
120 did not want to introduce a dependency on an XS module when all I
121 really wanted was the function of that module's _INSTANCE() subroutine.
122
124 Support is by the author. Please file bug reports at
125 <https://rt.cpan.org/Public/Dist/Display.html?Name=PPIx-Regexp>,
126 <https://github.com/trwyant/perl-PPIx-Regexp/issues>, or in electronic
127 mail to the author.
128
130 Thomas R. Wyant, III wyant at cpan dot org
131
133 Copyright (C) 2010-2023 by Thomas R. Wyant, III
134
135 This program is free software; you can redistribute it and/or modify it
136 under the same terms as Perl 5.10.0. For more details, see the full
137 text of the licenses in the directory LICENSES.
138
139 This program is distributed in the hope that it will be useful, but
140 without any warranty; without even the implied warranty of
141 merchantability or fitness for a particular purpose.
142
143
144
145perl v5.38.0 2023-07-21 PPIx::Regexp::Util(3)