Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ppix::editortools::renamepackage(3pm) [debian man page]

PPIx::EditorTools::RenamePackage(3pm)			User Contributed Perl Documentation		     PPIx::EditorTools::RenamePackage(3pm)

NAME
PPIx::EditorTools::RenamePackage - Change the package name SYNOPSIS
my $munged = PPIx::EditorTools::RenamePackage->new->rename( code => "package TestPackage; use strict; BEGIN { $^W = 1; } 1; ", replacement => 'NewPackage' ); my $new_code_as_string = $munged->code; my $package_ppi_element = $munged->element; DESCRIPTION
This module uses PPI to change the package name of code. METHODS
new() Constructor. Generally shouldn't be called with any arguments. rename( ppi => PPI::Document $ppi, replacement => Str ) =item rename( code => Str $code, replacement => Str ) Accepts either a "PPI::Document" to process or a string containing the code (which will be converted into a "PPI::Document") to process. Replaces the package name with that 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 "string", respectively. Croaks with a "package name not found" exception if unable to find the package name. SEE ALSO
This class inherits from "PPIx::EditorTools". Also see App::EditorTools, Padre, and PPI. perl v5.14.2 2012-03-11 PPIx::EditorTools::RenamePackage(3pm)

Check Out this Related Man Page

PPIx::EditorTools::ReturnObject(3pm)			User Contributed Perl Documentation		      PPIx::EditorTools::ReturnObject(3pm)

NAME
PPIx::EditorTools::ReturnObject - Simple object to return values from PPIx::EditorTools SYNOPSIS
my $brace = PPIx::EditorTools::FindUnmatchedBrace->new->find( code => "package TestPackage; sub x { 1; " ); my $location = $brace->element->location; my $ppi = $brace->element->ppi; DESCRIPTION
Retuning a simple "PPI::Element" from many of the "PPIx::EditorTools" methods often results in the loss of the overall context for that element. "PPIx::EditorTools::ReturnObject" provides an object that can be passed around which retains the overall context. For example, in "PPIx::EditorTools::FindUnmatchedBrace" if the unmatched brace were returned by its "PPI::Structure::Block" the containing "PPI::Document" is likely to go out of scope, thus the "location" method no longer returns a valid location (rather it returns undef). Using the "ReturnObject" preserves the "PPI::Document" and the containing context. METHODS
new() Constructor which should be used by "PPIx::EditorTools". Accepts the following named parameters: ppi A "PPI::Document" representing the (possibly modified) code. code A string representing the (possibly modified) code. element A "PPI::Element" or a subclass thereof representing the interesting element. ppi Accessor to retrieve the "PPI::Document". May create the "PPI::Document" from the $code string (lazily) if needed. code Accessor to retrieve the string representation of the code. May be retrieved from the "PPI::Document" via the serialize method (lazily) if needed. SEE ALSO
"PPIx::EditorTools", App::EditorTools, Padre, and PPI. perl v5.14.2 2012-03-11 PPIx::EditorTools::ReturnObject(3pm)
Man Page