PPIx::...ariable(3pm)
π PPIx::...ariable(3pm) β the manual page, but make it fashion π
okay bestie, gather round, because today we're talking about PPIx::EditorTools::RenameVariable β it lives in the User Contributed Perl Documentation section, and yeah the manual name up top is a little cursed (PPIx::...ariable(3pm), they really said "abbreviate the middle, it'll be fine") but the module itself? iconic. it lexically replaces variable names in Perl code. that's the whole gig. slay. π
β¨ VERSION β¨
version 0.21</purl> β that's the one, no cap. π
π SYNOPSIS π
look at her go:
my $munged = PPIx::EditorTools::RenameVariable->new->rename(
code => $code,
line => 15,
column => 13,
replacement => 'stuff',
);
my $code_as_strig = $munged->code;
my $code_as_ppi = $munged->ppi;
my $location = $munged->element->location;
(yes, $code_as_strig is spelled like that in the original. we do not fix it. we respect her. π«Ά)
π¦ DESCRIPTION π¦
bestie. this module lexically replaces a variable name. that's it, that's the vibe. it finds the variable, it swaps the name, it moves on with main character energy. β¨
π METHODS π
πΈ new()
constructor energy. generally shouldn't be called with any arguments β like, just let her be, she knows what she's doing. π
πΈ rename( ppi => PPI::Document $ppi, line => Int, column => Int, replacement => Str )
πΈ rename( code => Str $code, line => Int, column => Int, replacement => Str )
πΈ rename( code => Str $code, line => Int, column => Int, to_camel_case => Bool, [ucfirst => Bool] )
πΈ rename( code => Str $code, line => Int, column => Int, from_camel_case => Bool, [ucfirst => Bool] )
so here's the tea β β you hand her either a PPI::Document to process, or a string with the code in it (and she'll convert that into a PPI::Document herself, she's capable). then she renames the variable found at line, column with whatever you put in the replacement parameter. and she gives you back a PPIx::EditorTools::ReturnObject with the new code chillin' in the ppi or code accessors β as a PPI::Document or a string, respectively, iykyk. the PPI::Token she found at line, column? that's available through the element accessor. π
and listen β instead of specifying an explicit replacement variable name, you can use the to_camel_case or from_camel_case options, which automatically convert to/from camelCase. in that mode, the ucfirst option will force uppercasing of the first letter. lowercase-to-Uppercase glow-up, we love to see it. π₯
β οΈ but fr fr: you can not specify a replacement name and use the to/from_camel_case options. pick a lane, bestie. not both. π«
and the dramatic parts, because we keep it real:
- she croaks with a
"no token"exception if no token is found at the location. π - she croaks with a
"no declaration"exception if she's unable to find the declaration. π
π SEE ALSO π
this class inherits from PPIx::EditorTools. also go look at App::EditorTools, Padre, and PPI. the whole friend group. π«Ά
π AUTHORS π
the legends, in order:
- Steffen Mueller
smueller@cpan.org - Mark Grimes
mgrimes@cpan.org - Ahmad M. Zawawi <ahmad.zawawi@gmail.com>
- Gabor Szabo <gabor@szabgab.com>
- Yanick Champoux <yanick@cpan.org>
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2017, 2014, 2012 by The Padre development team as listed in Padre.pm..
and it's free software, bestie β you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt. π
and that's the whole page, mwah π β this lil doc came to you from perl v5.34.0, dated 2022-06-17, and it's the PPIx::...ariable(3pm) page. go rename something. stay hydrated. ππ§
π¦ where this page comes from
- debian bookworm: libppix-editortools-perl 0.21-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libppix-editortools-perl 0.21-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libppix-editortools-perl 0.21-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libppix-editortools-perl 0.21-2 Β· 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