PPIx::R...en::Code(3)

πŸ’– NAME πŸ’–

PPIx::Regexp::Token::Code β€” the class that reps a lil chunk of Perl code snuggled up inside a regular expression. 🫢


✨ SYNOPSIS ✨

use PPIx::Regexp::Dumper;
PPIx::Regexp::Dumper->new(
    'qr{(?{print "hello sailor\n"})}smx')->print;

🌸 INHERITANCE 🌸

PPIx::Regexp::Token::Code is a PPIx::Regexp::Token. It's giving "yes, that's the family tree, bestie." 🌳

And PPIx::Regexp::Token::Code is the parent of PPIx::Regexp::Token::Interpolation β€” so it's a mom too. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so this class is the vibe for a chunk of Perl code that's been embedded inside a regular expression. Specifically? It shows up when you parse stuff like

(?{ code })
(??{ code })

or when you're on the replacement side of an s///e. πŸ”₯

Technically, interpolations are also code, but they parse differently, so they end up in a whole different token. Different token, different era, iykyk. πŸ’…

⚠️ This token may not appear inside a regex set (i.e. (?[ ... ]). If it does get found there, it becomes a PPIx::Regexp::Token::Unknown. So don't do that. 🚫

πŸ’… METHODS πŸ’…

This class provides the following public methods. Methods that aren't documented here are private, and unsupported in the sense that the author reserves the right to change or remove them without notice. (So like… don't get attached. 😭)

🌟 is_matcher

This method returns undef because a static analysis can not in general tell whether an interpolated value matches anything. It literally cannot know. Mystery is the whole point. ✨

🌟 ppi

This convenience method returns the PPI::Document representing the content. This document should be considered read only. 🚫✍️

Note that if the location of the invocant is available, the PPI document will have stuff prefixed to it to make the location of the tokens in the new document consistent with the location. This "stuff" will include at least a #line directive, and maybe leading white space. That's it, that's the stuff. πŸŽ€


🫢 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 wants the bug reports, fr fr. πŸ›πŸ’Œ


πŸ‘‘ AUTHOR πŸ‘‘

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


Copyright (C) 2009-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. (No promises, bestie, that's the deal. πŸ’€)


And that's a wrap!! πŸŽ€ This gem of a page came out of perl v5.42.2, dated 2026-06-15, and it lives in the User Contributed Perl Documentation corner of the manual. Slay, go write some regex code blocks. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from