<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
require 5;
package Pod::Simple::PullParserToken;
 # Base class for tokens gotten from Pod::Simple::PullParser's $parser-&gt;get_token
@ISA = ();
$VERSION = '3.28';
use strict;

sub new {  # Class-&gt;new('type', stuff...);  ## Overridden in derived classes anyway
  my $class = shift;
  return bless [@_], ref($class) || $class;
}

sub type { $_[0][0] }  # Can't change the type of an object
sub dump { Pod::Simple::pretty( [ @{ $_[0] } ] ) }

sub is_start { $_[0][0] eq 'start' }
sub is_end   { $_[0][0] eq 'end'   }
sub is_text  { $_[0][0] eq 'text'  }

1;
__END__

sub dump { '[' . _esc( @{ $_[0] } ) . ']' }

# JUNK:

sub _esc {
  return '' unless @_;
  my @out;
  foreach my $in (@_) {
    push @out, '"' . $in . '"';
    $out[-1] =~ s/([^- \:\:\.\,\'\&gt;\&lt;\"\/\=\?\+\|\[\]\{\}\_a-zA-Z0-9_\`\~\!\#\%\^\&amp;\*\(\)])/
      sprintf( (ord($1) &lt; 256) ? "\\x%02X" : "\\x{%X}", ord($1))
    /eg;
  }
  return join ', ', @out;
}


__END__

=head1 NAME

Pod::Simple::PullParserToken -- tokens from Pod::Simple::PullParser

=head1 SYNOPSIS

Given a $parser that's an object of class Pod::Simple::PullParser
(or a subclass)...

  while(my $token = $parser-&gt;get_token) {
    $DEBUG and print "Token: ", $token-&gt;dump, "\n";
    if($token-&gt;is_start) {
      ...access $token-&gt;tagname, $token-&gt;attr, etc...

    } elsif($token-&gt;is_text) {
      ...access $token-&gt;text, $token-&gt;text_r, etc...

    } elsif($token-&gt;is_end) {
      ...access $token-&gt;tagname...

    }
  }

(Also see L&lt;Pod::Simple::PullParser&gt;)

=head1 DESCRIPTION

When you do $parser-&gt;get_token on a L&lt;Pod::Simple::PullParser&gt;, you should
get an object of a subclass of Pod::Simple::PullParserToken.

Subclasses will add methods, and will also inherit these methods:

=over

=item $token-&gt;type

This returns the type of the token.  This will be either the string
"start", the string "text", or the string "end".

Once you know what the type of an object is, you then know what
subclass it belongs to, and therefore what methods it supports.

Yes, you could probably do the same thing with code like
$token-&gt;isa('Pod::Simple::PullParserEndToken'), but that's not so
pretty as using just $token-&gt;type, or even the following shortcuts:

=item $token-&gt;is_start

This is a shortcut for C&lt;&lt; $token-&gt;type() eq "start" &gt;&gt;

=item $token-&gt;is_text

This is a shortcut for C&lt;&lt; $token-&gt;type() eq "text" &gt;&gt;

=item $token-&gt;is_end

This is a shortcut for C&lt;&lt; $token-&gt;type() eq "end" &gt;&gt;

=item $token-&gt;dump

This returns a handy stringified value of this object.  This
is useful for debugging, as in:

  while(my $token = $parser-&gt;get_token) {
    $DEBUG and print "Token: ", $token-&gt;dump, "\n";
    ...
  }

=back

=head1 SEE ALSO

My subclasses:
L&lt;Pod::Simple::PullParserStartToken&gt;,
L&lt;Pod::Simple::PullParserTextToken&gt;, and
L&lt;Pod::Simple::PullParserEndToken&gt;.

L&lt;Pod::Simple::PullParser&gt; and L&lt;Pod::Simple&gt;

=head1 SUPPORT

Questions or discussion about POD and Pod::Simple should be sent to the
pod-people@perl.org mail list. Send an empty email to
pod-people-subscribe@perl.org to subscribe.

This module is managed in an open GitHub repository,
L&lt;https://github.com/theory/pod-simple/&gt;. Feel free to fork and contribute, or
to clone L&lt;git://github.com/theory/pod-simple.git&gt; and send patches!

Patches against Pod::Simple are welcome. Please send bug reports to
&lt;bug-pod-simple@rt.cpan.org&gt;.

=head1 COPYRIGHT AND DISCLAIMERS

Copyright (c) 2002 Sean M. Burke.

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

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.

=head1 AUTHOR

Pod::Simple was created by Sean M. Burke &lt;sburke@cpan.org&gt;.
But don't bother him, he's retired.

Pod::Simple is maintained by:

=over

=item * Allison Randal C&lt;allison@perl.org&gt;

=item * Hans Dieter Pearcey C&lt;hdp@cpan.org&gt;

=item * David E. Wheeler C&lt;dwheeler@cpan.org&gt;

=back

=cut
</pre></body></html>