1
2require 5;
3package Pod::Simple::PullParserTextToken;
4use Pod::Simple::PullParserToken ();
5use strict;
6use vars qw(@ISA $VERSION);
7@ISA = ('Pod::Simple::PullParserToken');
8$VERSION = '3.43';
9
10sub new {  # Class->new(text);
11  my $class = shift;
12  return bless ['text', @_], ref($class) || $class;
13}
14
15# Purely accessors:
16
17sub text { (@_ == 2) ? ($_[0][1] = $_[1]) : $_[0][1] }
18
19sub text_r { \ $_[0][1] }
20
211;
22
23__END__
24
25=head1 NAME
26
27Pod::Simple::PullParserTextToken -- text-tokens from Pod::Simple::PullParser
28
29=head1 SYNOPSIS
30
31(See L<Pod::Simple::PullParser>)
32
33=head1 DESCRIPTION
34
35When you do $parser->get_token on a L<Pod::Simple::PullParser>, you might
36get an object of this class.
37
38This is a subclass of L<Pod::Simple::PullParserToken> and inherits all its methods,
39and adds these methods:
40
41=over
42
43=item $token->text
44
45This returns the text that this token holds.  For example, parsing
46CZ<><foo> will return a C start-token, a text-token, and a C end-token.  And
47if you want to get the "foo" out of the text-token, call C<< $token->text >>
48
49=item $token->text(I<somestring>)
50
51This changes the string that this token holds.  You probably won't need
52to do this.
53
54=item $token->text_r()
55
56This returns a scalar reference to the string that this token holds.
57This can be useful if you don't want to memory-copy the potentially
58large text value (well, as large as a paragraph or a verbatim block)
59as calling $token->text would do.
60
61Or, if you want to alter the value, you can even do things like this:
62
63  for ( ${  $token->text_r  } ) {  # Aliases it with $_ !!
64
65    s/ The / the /g; # just for example
66
67    if( 'A' eq chr(65) ) {  # (if in an ASCII world)
68      tr/\xA0/ /;
69      tr/\xAD//d;
70    }
71
72    ...or however you want to alter the value...
73    (Note that starting with Perl v5.8, you can use, e.g.,
74
75        my $nbsp = chr utf8::unicode_to_native(0xA0);
76        s/$nbsp/ /g;
77
78    to handle the above regardless if it's an ASCII world or not)
79  }
80
81=back
82
83You're unlikely to ever need to construct an object of this class for
84yourself, but if you want to, call
85C<<
86Pod::Simple::PullParserTextToken->new( I<text> )
87>>
88
89=head1 SEE ALSO
90
91L<Pod::Simple::PullParserToken>, L<Pod::Simple>, L<Pod::Simple::Subclassing>
92
93=head1 SUPPORT
94
95Questions or discussion about POD and Pod::Simple should be sent to the
96pod-people@perl.org mail list. Send an empty email to
97pod-people-subscribe@perl.org to subscribe.
98
99This module is managed in an open GitHub repository,
100L<https://github.com/perl-pod/pod-simple/>. Feel free to fork and contribute, or
101to clone L<git://github.com/perl-pod/pod-simple.git> and send patches!
102
103Patches against Pod::Simple are welcome. Please send bug reports to
104<bug-pod-simple@rt.cpan.org>.
105
106=head1 COPYRIGHT AND DISCLAIMERS
107
108Copyright (c) 2002 Sean M. Burke.
109
110This library is free software; you can redistribute it and/or modify it
111under the same terms as Perl itself.
112
113This program is distributed in the hope that it will be useful, but
114without any warranty; without even the implied warranty of
115merchantability or fitness for a particular purpose.
116
117=head1 AUTHOR
118
119Pod::Simple was created by Sean M. Burke <sburke@cpan.org>.
120But don't bother him, he's retired.
121
122Pod::Simple is maintained by:
123
124=over
125
126=item * Allison Randal C<allison@perl.org>
127
128=item * Hans Dieter Pearcey C<hdp@cpan.org>
129
130=item * David E. Wheeler C<dwheeler@cpan.org>
131
132=back
133
134=cut
135