GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  PPIX::EDITORTOOLS::INTRODUCETEMPORARYVARIABLE (3)

.ds Aq ’

NAME

PPIx::EditorTools::IntroduceTemporaryVariable - Introduces a temporary variable using PPI

CONTENTS

SYNOPSIS



    my $munged = PPIx::EditorTools::IntroduceTemporaryVariable->new->introduce(
        code           => "use strict; BEGIN {
        $^W = 1;
}\n\tmy $x = ( 1 + 10 / 12 ) * 2;\n\tmy $y = ( 3 + 10 / 12 ) * 2;\n",
        start_location => [ 2, 19 ],
        end_location   => [ 2, 25 ],
        varname        => $foo,
    );
    my $modified_code_as_string = $munged->code;
    my $location_of_new_var_declaration = $munged->element->location;



DESCRIPTION

Given a region of code within a statement, replaces all occurrences of that code with a temporary variable. Declares and initializes the temporary variable right above the statement that included the selected expression.

METHODS

new() Constructor. Generally shouldn’t be called with any arguments.
find( ppi => PPI::Document, start_location => Int, end_location => Int, varname => Str ) =item find( code => Str, start_location => Int, end_location => Int, varname => Str ) Accepts either a PPI::Document to process or a string containing the code (which will be converted into a PPI::Document) to process.

Given the region of code specified by start_location and end_location, replaces that code with a temporary variable with the name given in varname (defaults to tmp). Declares and initializes the temporary variable right above the statement that included the selected expression.

Returns a PPIx::EditorTools::ReturnObject with the modified code as a string available via the code accessor (or as a PPI::Document via the ppi accessor), and the PPI::Token where the new variable is declared available via the element accessor.

Croaks with a no token exception if no token is found at the location. Croaks with a no statement exception if unable to find the statement.

SEE ALSO

This class inherits from PPIx::EditorTools. Also see App::EditorTools, Padre, and PPI.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 PPIX::EDITORTOOLS::INTRODUCETEMPORARYVARIABLE (3) 2014-09-03

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.