PPIx::Regexp::Util - Utility functions for PPIx::Regexp;
use PPIx::Regexp::Util qw{ __instance }; . . . __instance( $foo, 'Bar' ) or die '$foo is not a Bar';
This module contains utility functions for PPIx::Regexp which it is convenient to centralize.
Double-underscore subroutines are private to the PPIx-Regexp package. Their documentation is provided for the author's convenience only, and they are subject to change without notice. Caveat user.
PPIx-Regexp
This module exports nothing by default.
This module can export the following subroutines:
is_ppi_regexp_element( $elem ) and print "$elem is a regexp of some sort\n";
This subroutine is public and supported.
This subroutine takes as its argument a PPI::Element. It returns a true value if the argument represents a regular expression of some sort, and a false value otherwise.
__instance( $foo, 'Bar' ) and print '$foo isa Bar', "\n";
This subroutine is private to the PPIx-Regexp package.
This subroutine returns true if its first argument is an instance of the class specified by its second argument. Unlike UNIVERSAL::isa, the result is always false unless the first argument is a reference.
UNIVERSAL::isa
__is_ppi_regexp_element( $elem ) and print "$elem is a regexp of some sort\n";
This is a synonym for is_ppi_regexp_element(), and is deprecated in favor of it. If called, it will complain via Carp::cluck() and then goto &is_ppi_regexp_element.
Carp::cluck()
goto &is_ppi_regexp_element
This subroutine merges perl requirements as returned by the various __perl_requirements() methods.
__perl_requirements()
This method is analogous to can(), but returns a reference to the code only if it is actually implemented by the invoking name space.
can()
This method is private to the PPIx-Regexp package. The intended use is to alias it to __PPIX_ELEM__post_reblessing().
__PPIX_ELEM__post_reblessing()
It takes arguments as name/value pairs. Argument {error} is the error message; if it is omitted you get a warning with stack trace. Argument {explanation} defaults to {error}.
{error}
{explanation}
It returns the number of errors to add to the parse.
This public method returns the minimum and maximum width matched by the element before taking into account such details as what the element actually is and how it is quantified.
This implementation is appropriate to things that match exactly one character -- i.e. it returns ( 1, 1 ).
( 1, 1 )
This subroutine takes as its argument an integer and returns a string representing its ordinal in English. For example
say __to_ordinal_en( 17 ); # 17th
my ( $min_wid, $max_wid ) = $self->width();
This public method (well, mixin) returns the minimum and maximum width of the text matched by the element.
Elements which import this method must also implement a raw_width() method which returns the unquantified width of the element.
raw_width()
The following export tags are defined by this module. All are private to the PPIx-Regexp package unless otherwise documented.
This tag exports everything exportable by this module.
This tag is appropriate to an element which, when unquantified, matches exactly one character. It exports raw_width() and width().
width()
Params::Util, which I recommend, but in the case of PPIx::Regexp I did not want to introduce a dependency on an XS module when all I really wanted was the function of that module's _INSTANCE() subroutine.
PPIx::Regexp
_INSTANCE()
Support is by the author. Please file bug reports at https://rt.cpan.org/Public/Dist/Display.html?Name=PPIx-Regexp, https://github.com/trwyant/perl-PPIx-Regexp/issues, or in electronic mail to the author.
Thomas R. Wyant, III wyant at cpan dot org
Copyright (C) 2010-2022 by Thomas R. Wyant, III
This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
To install PPIx::Regexp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PPIx::Regexp
CPAN shell
perl -MCPAN -e shell install PPIx::Regexp
For more information on module installation, please visit the detailed CPAN module installation guide.