SYNOPSIS

    my $munged = PPIx::EditorTools::RenamePackage->new->rename(
        code        => "package TestPackage;\nuse strict;\nBEGIN {
        $^W = 1;
}\n1;\n",
        replacement => 'NewPackage'
    );

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

DESCRIPTION

This module uses \s-1PPI\s0 to change the package name of code.

METHODS

new()

Constructor. Generally shouldn't be called with any arguments. Accepts either a \*(C`PPI::Document\*(C' to process or a string containing the code (which will be converted into a \*(C`PPI::Document\*(C') to process. Replaces the package name with that supplied in the \*(C`replacement\*(C' parameter and returns a \*(C`PPIx::EditorTools::ReturnObject\*(C' with the new code available via the \*(C`ppi\*(C' or \*(C`code\*(C' accessors, as a \*(C`PPI::Document\*(C' or \*(C`string\*(C', respectively. Croaks with a \*(L"package name not found\*(R" exception if unable to find the package name.

RELATED TO PPIx::EditorTools::RenamePackage…

This class inherits from \*(C`PPIx::EditorTools\*(C'. Also see App::EditorTools, Padre, and \s-1PPI\s0.