PPIx::...ackage(3pm)

πŸ“¦
version 0.21 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute

πŸ’– PPIx::EditorTools::RenamePackage β€” change the package name πŸ’–

okay bestie, welcome to the PPIx::...ackage page, from the User Contributed Perl Documentation corner of the manual universe πŸ¦‹ this one is PPIx::EditorTools::RenamePackage and it does exactly one thing but it does it so well, no cap.


✨ NAME ✨

PPIx::EditorTools::RenamePackage β€” change the package name πŸ’…


🌸 VERSION 🌸

version 0.21


πŸŽ€ SYNOPSIS πŸŽ€

my $munged = PPIx::EditorTools::RenamePackage->new->rename(
    code        => <<'END_CODE',
        package TestPackage;
        use strict;

        BEGIN { $^W = 1; }
        1;
END_CODE
    replacement => 'NewPackage'
);

my $new_code_as_string = $munged->code;
my $package_ppi_element = $munged->element;

like. look at her. she's glowing ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

This module uses PPI to change the package name of code. that's the whole vibe. it reads your code, it finds the package name, it swaps it out. iconic behaviour fr fr πŸ‘‘


πŸ’… METHODS πŸ’…

new()

Constructor. Generally shouldn't be called with any arguments. like, she's lowkey self-sufficient, just let her cook πŸ“

rename( ppi => PPI::Document $ppi, replacement => Str )

rename( code => Str $code, replacement => Str )

She accepts either a PPI::Document to process or a string containing the code (which will be converted into a PPI::Document) to process. So you can hand her the fancy object or just yeet her a string, both are valid, she's flexible like that 🧚

She replaces the package name with whatever you supplied in the replacement parameter, and returns a PPIx::EditorTools::ReturnObject with the new code available via the ppi or code accessors β€” as a PPI::Document or a string, respectively. pick your fighter πŸ’–

⚠️ She croaks with a package name not found exception if she's unable to find the package name. so like, if there's no package in there? she WILL be dramatic about it. that's the deal. 😭

🌈 SEE ALSO 🌈

This class inherits from PPIx::EditorTools. Also peep App::EditorTools, Padre, and PPI β€” the whole friend group honestly 🫢


πŸ‘‘ AUTHORS πŸ‘‘

  • 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>`

the collective. the squad. the main characters ✨


This software is copyright (c) 2017, 2014, 2012 by The Padre development team as listed in Padre.pm.. (yes bestie there are two periods, that's canon, don't @ me πŸ™ˆ)

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay, legally speaking πŸ’…


and that's the page!! this little cutie came to you courtesy of perl v5.34.0 on 2022-06-17, and honestly? she ate. periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from