PPIx::Regexp::Util(3)

πŸ’– PPIx::Regexp::Util β€” the manual page, but make it cute πŸ’–

okay so bestie, welcome to PPIx::Regexp::Util(3) β€” a User Contributed Perl Documentation page, which is giving very "the lore drop nobody asked for but everyone needs". Pull up a chair, grab a boba, we're doing utility functions. ✨


🌸 NAME 🌸

PPIx::Regexp::Util β€” utility functions for PPIx::Regexp; (yes the semicolon is part of the vibe, we don't ask questions)


πŸŽ€ SYNOPSIS πŸŽ€

Like, here's the whole thing in action:

use PPIx::Regexp::Util qw{ __instance };
    .
    .
    .
__instance( $foo, 'Bar' )
    or die '$foo is not a Bar';

the little dots are doing SO much work there, iconic honestly πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

This module is where all the utility functions for PPIx::Regexp live, because it was convenient to centralize them. Group project but the one person who actually does the work, you know? 😭

Double-underscore subroutines are private to the PPIx-Regexp package. Their documentation exists purely for the author's convenience, and ngl, they are subject to change without notice. Caveat user. Like fr fr, do not build your whole personality on these. πŸ’€

This module exports nothing by default. Not a thing. Zero. You gotta ask. πŸ™ˆ


πŸ‘‘ SUBROUTINES πŸ‘‘

The module can export the following subroutines, bestie β€” here's the whole roster, no skips:

⭐ is_ppi_regexp_element

is_ppi_regexp_element( $elem )
  and print "$elem is a regexp of some sort\n";

This one is public and supported β€” main character energy, fully safe to use. πŸ’–

It takes a PPI::Element as its argument. Returns true if that argument represents a regular expression of some sort, false otherwise. That's it. That's the whole job. Slay. ✨


πŸ’œ __instance

__instance( $foo, 'Bar' )
    and print '$foo isa Bar', "\n";

This subroutine is private to the PPIx-Regexp package.

It returns true if its first argument is an instance of the class named by its second argument. BUT β€” and this is the plot twist β€” unlike UNIVERSAL::isa, the result is always false unless the first argument is a reference. The way that UNIVERSAL::isa just lets anything slide and this one is picky about it… honestly? Boundaries. We love to see it. 🫢


πŸ“ __is_ppi_regexp_element

__is_ppi_regexp_element( $elem )
  and print "$elem is a regexp of some sort\n";

This subroutine is private to the PPIx-Regexp package.

It's a synonym for is_ppi_regexp_element(), and it is deprecated in favor of it. Deprecated, bestie. That's the "we're still friends but this is over" of API design. 😭 If you call it anyway, it will complain via Carp::cluck() and then goto &is_ppi_regexp_element. So it complains AND does the thing anyway. Relatable, honestly.


🌈 __merge_perl_requirements

This subroutine is private to the PPIx-Regexp package.

It merges perl requirements as returned by the various "__perl_requirements()" methods. Fusion dance for version requirements. ✨


🧚 __ns_can

This subroutine is private to the PPIx-Regexp package.

This method is analogous to can(), but it returns a reference to the code only if it is actually implemented by the invoking name space. No inherited hand-me-downs here, we only accept the real thing. πŸ’…


🌸 __post_rebless_error

This method is private to the PPIx-Regexp package. The intended use is to alias it to "__PPIX_ELEM__post_reblessing()".

It takes arguments as name/value pairs:

  • {error} is the error message. If you omit it, you get a warning with stack trace. Surprise! πŸŽ‰
  • {explanation} defaults to {error}.

It returns the number of errors to add to the parse. A little counter of chaos. πŸ“Š


πŸ’– raw_width

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. So like, the raw numbers, pre-glow-up. ✨

This implementation is appropriate to things that match exactly one character β€” i.e. it returns ( 1, 1 ). Consistent. Reliable. A little boring but in a comforting way. πŸ₯°


πŸŽ€ __to_ordinal_en

This subroutine is private to the PPIx-Regexp package.

It takes an integer as its argument and returns a string representing its ordinal in English. For example:

say __to_ordinal_en( 17 );
# 17th

seventeenth but make it a string πŸ₯Ή


πŸ”₯ width

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. That's the deal. You want the fancy one, you bring the raw one. No shortcuts. 🫢


🎁 EXPORT TAGS 🎁

The following export tags are defined by this module. All are private to the PPIx-Regexp package unless otherwise documented.

⭐ all

This tag exports everything exportable by this module. Go big or go home. πŸ”₯

πŸ’œ width_one

This tag is appropriate to an element which, when unquantified, matches exactly one character. It exports raw_width() and width(). The buddy system, but for methods. 🫢


πŸ‘€ SEE ALSO πŸ‘€

  • Params::Util β€” which the author recommends, but in the case of PPIx::Regexp the author did not want to introduce a dependency on an XS module when all that was really wanted was the function of that module's _INSTANCE() subroutine. So we built our own. DIY era. πŸ’…

🫢 SUPPORT 🫢

Support is by the author. Please file bug reports at <https://github.com/trwyant/perl-PPIx-Regexp/issues> or in electronic mail to the author. He's nice, he wants to hear from you, don't be shy. ✨


πŸ‘‘ AUTHOR πŸ‘‘

Thomas R. Wyant, III β€” harryfmudd at comcast dot net


Copyright (C) 2010-2023, 2025-2026 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. That's the legal way of saying "girl, good luck" β€” so fr fr, don't sue. 😭


and that's the whole page, bestie πŸŽ€ β€” this was perl v5.42.2, dated 2026-06-15, signing off with a little curtsy πŸ’…βœ¨ stay regexp-ing, you got this πŸ‘‘

πŸ“¦ where this page comes from