B::Hooks::Parser(3pm)
β¨ B::Hooks::Parser β¨
okay bestie, so this is a page from the User Contributed Perl Documentation section, and the module in question is B::Hooks::Parser π
πΈ NAME πΈ
B::Hooks::Parser β your lil backstage pass to perl's parser variables π
π VERSION π
version 0.21 (yes queen, she's been around a minute)
π¦ DESCRIPTION π¦
So basically this module hands you an API for parts of the perl parser π and the whole point is that you can go in there and modify code while it's literally being parsed. That's right, mid-parse glow-ups only. Main character energy fr fr β¨
π§ Perl API π§
setup()
Does some initialization work. π« Lowkey crucial: you must call this before any other functions of this module if you intend to use set_linestr. It returns an id, and you can use that id to disable the magic with teardown. πͺ
teardown($id)
Disables the magic registered using setup. poof, no more magic β¨
get_linestr()
Returns the line the parser is currently working on π or undef if perl isn't parsing anything right now. (nothing's happening, it's giving silence π)
get_linestr_offset()
Returns the position within the current line to which perl has already parsed the input. If nothing is being parsed currently, you get -1. that's it, that's the vibe π
set_linestr($string)
Sets the line the perl parser is currently working on to $string. iconic.
β οΈ important bestie: perl won't notice any changes in the line string after the position returned by get_linestr_offset. so anything you scribble past that point? perl is not looking. π
Also β it throws an exception when nothing is being compiled. π no compile, no dice.
inject($string)
Convenience function β¨ it inserts a piece of perl code into the current line string (as returned by get_linestr) at the current offset (as returned by get_linestr_offset). slay, little code injection π
get_lex_stuff()
Returns the string of additional stuff resulting from recent lexing that is being held onto by the lexer. For example, the content of a quoted string goes here π. Returns "undef" if there is no such stuff.
clear_lex_stuff()
Discard the string of additional stuff resulting from recent lexing that is being held onto by the lexer. π§Ή bye bestie
π C API π
The following functions work just like their equivalent in the Perl API β except they can't handle embedded NUL bytes in strings. no NULs, we don't do that here π«
"hook_op_check_id hook_parser_setup (void)"β Note: may be implemented as a macro. π«Ά"void hook_parser_teardown (hook_op_check_id id)""const char *hook_parser_get_linestr (pTHX)""IV hook_parser_get_linestr_offset (pTHX)""void hook_parser_set_linestr (pTHX_ const char *new_value)""char *hook_parser_get_lex_stuff (pTHX)""void hook_parser_clear_lex_stuff (pTHX)"
π SUPPORT π
Bugs may be submitted through the RT bug tracker β https://rt.cpan.org/Public/Dist/Display.html?Name=B-Hooks-Parser β or over email at bug-B-Hooks-Parser@rt.cpan.org π¬ (fr fr, they wanna hear about it)
π AUTHOR π
Florian Ragwitz <rafl@debian.org>
π CONTRIBUTORS π
- Karen Etheridge
<ether@cpan.org> - Zefram
<zefram@fysh.org> - Vincent Pit
<perl@profvince.com> - Alexandr Ciornii
<alexchorny@gmail.com> - Karl Williamson
<khw@cpan.org> - Liu Kang-min
<gugod@gugod.org>
(legends, every single one π)
π COPYRIGHT AND LICENCE π
This software is copyright (c) 2008 by Florian Ragwitz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. π©·
and that's the whole page bestie!! π this doc was served up by perl v5.42.3, dated 2026-08-20 β mwah, go code, you got this π¦β¨
π¦ where this page comes from
- ubuntu stonking: libb-hooks-parser-perl 0.21-3build3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms