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
PPIx::QuoteLike::Utils(3) User Contributed Perl Documentation PPIx::QuoteLike::Utils(3)

PPIx::QuoteLike::Utils - Utility subroutines for PPIx::QuoteLike;

 use PPIx::QuoteLike::Utils qw{ __variables };
 
 say for __variables( PPI::Document->new( \'$foo' );

This Perl module holds code for PPIx::QuoteLike that did not seem to fit anywhere else.

This module supports the following public subroutines:

This subroutine/method returns the column number of the first character in the element, or "undef" if that can not be determined.

This subroutine returns true if its argument is a PPI::Element that this package is capable of dealing with. That is, one of the following:

    PPI::Token::Quote
    PPI::Token::QuoteLike::Backtick
    PPI::Token::QuoteLike::Command
    PPI::Token::QuoteLike::Readline
    PPI::Token::HereDoc

It returns false for unblessed references and for non-references.

This subroutine/method returns the line number of the first character in the element, or "undef" if that can not be determined.

This subroutine/method returns the logical file name (taking "#line" directives into account) of the file containing first character in the element, or "undef" if that can not be determined.

This subroutine/method returns the logical line number (taking "#line" directives into account) of the first character in the element, or "undef" if that can not be determined.

Despite the leading underscores, this exportable subroutine is public and supported. The underscores are so it will not appear to be public code to various tools when imported into other code.

This subroutine takes as its argument a string representing an interpolation. It removes such things as braces around variable names to make it into more normal Perl -- which is to say Perl that produces a more normal PPI parse. Sample transformations are:

 '${foo}'        => '$foo'
 '@{[ foo() ]}'  => 'foo()'
 '${\( foo() )}' => 'foo()'

NOTE that this is not intended for general code cleanup. Specifically, it assumes that its argument is an interpolation and only an interpolation. Feeding it anything else is unsupported, and probably will not return anything useful.

This subroutine/method returns the PPI::Statement that contains this element, or nothing if the statement can not be determined.

In general this method will return something only under the following conditions:

  • The element is contained in a PPIx::Regexp object;
  • That object was initialized from a PPI::Element;
  • The PPI::Element is contained in a statement.

This subroutine/method returns the visual column number (taking tabs into account) of the first character in the element, or "undef" if that can not be determined.

 say for __variables( PPI::Document->new( \'$foo' );

NOTE that this subroutine is discouraged, and may well be deprecated and removed. My problem with it is that it returns variable names rather than PPI::Element objects, leaving you no idea how the variables are used. It was originally written for the benefit of Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter, but has proven inadequate to that policy's needs.

Despite the leading underscores, this exportable subroutine is public and supported. The underscores are so it will not appear to be public code to various tools when imported into other code.

This subroutine takes as its only argument a PPI::Element, and returns the names of all variables found in that element, in no particular order. Scope is not taken into account.

In addition to reporting variables parsed as such by PPI, and various corner cases such as "${]}" where PPI is blind to the use of the variable, this subroutine looks inside the following PPI classes:

    PPI::Token::Quote
    PPI::Token::QuoteLike::Backtick
    PPI::Token::QuoteLike::Command
    PPI::Token::QuoteLike::Readline
    PPI::Token::HereDoc

If PPIx::Regexp is installed, it will also look inside

    PPI::Token::QuoteLike::Regexp
    PPI::Token::Regexp::Match
    PPI::Token::Regexp::Substitute

Unfortunately I can not make "PPIx::Regexp" a requirement for this module, because of the possibility of a circular dependency.

Support is by the author. Please file bug reports at <https://rt.cpan.org/Public/Dist/Display.html?Name=PPIx-QuoteLike>, <https://github.com/trwyant/perl-PPIx-QuoteLike/issues>, or in electronic mail to the author.

Thomas R. Wyant, III wyant at cpan dot org

Copyright (C) 2016-2022 by Thomas R. Wyant, III

This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

2022-03-17 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

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