Adam Kennedy > PPI > PPI::Token::Magic

Download:
PPI-1.207_01.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  40
Open  29
View Bugs
Report a bug
Module Version: 1.207_01   Source  

NAME ^

PPI::Token::Magic - Tokens representing magic variables

INHERITANCE ^

  PPI::Token::Magic
  isa PPI::Token::Symbol
      isa PPI::Token
          isa PPI::Element

SYNOPSIS ^

  # When we say magic variables, we mean these...
  $1   $2   $3   $4   $5   $6   $7   $8   $9
  $_   $&   $`   $'   $+   @+   %+   $*   $.    $/    $|
  $\\  $"   $;   $%   $=   $-   @-   %-   $)    $#
  $~   $^   $:   $?   $!   %!   $@   $$   $<    $>
  $(   $0   $[   $]   @_   @*   $}   $,   $#+   $#-
  $^L  $^A  $^E  $^C  $^D  $^F  $^H
  $^I  $^M  $^N  $^O  $^P  $^R  $^S
  $^T  $^V  $^W  $^X

DESCRIPTION ^

PPI::Token::Magic is a sub-class of PPI::Token::Symbol which identifies the token as "magic variable", one of the strange and unusual variables that are connected to "things" behind the scenes.

Some are extremely common, like $_, and others you will quite probably never encounter in your Perl career.

METHODS ^

The class provides no additional methods, beyond those provided by it's PPI::Token::Symbol, PPI::Token and PPI::Element.

my $document = PPI::Document->new(\<<'END_PERL'); $[; # Magic $[ $$; # Magic $$ %-; # Magic %- $#-; # Magic $#- $$foo; # Symbol $foo Dereference of $foo $^W; # Magic $^W $^WIDE_SYSTEM_CALLS; # Magic $^WIDE_SYSTEM_CALLS ${^MATCH}; # Magic ${^MATCH} @{^_Bar}; # Magic @{^_Bar} ${^_Bar}[0]; # Magic @{^_Bar} %{^_Baz}; # Magic %{^_Baz} ${^_Baz}{burfle}; # Magic %{^_Baz} $${^MATCH}; # Magic ${^MATCH} Dereference of ${^MATCH} \${^MATCH}; # Magic ${^MATCH} END_PERL

isa_ok( $document, 'PPI::Document' );

$document->index_locations();

my $symbols = $document->find( 'PPI::Token::Symbol' );

is( scalar(@$symbols), 14, 'Found 14 symbols' ); my $comments = $document->find( 'PPI::Token::Comment' );

foreach my $token ( @$symbols ) { my ($hash, $class, $name, $remk) = split '\s+', $comments->[$token->line_number - 1], 4; isa_ok( $token, "PPI::Token::$class" ); is( $token->symbol, $name, $remk || "The symbol is $name" ); }

SUPPORT ^

See the support section in the main module.

AUTHOR ^

Adam Kennedy <adamk@cpan.org>

COPYRIGHT ^

Copyright 2001 - 2009 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.