This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Underscore the non-official version number
[perl5.git] / lib / Pod / Simple / PullParserTextToken.pm
CommitLineData
351625bd
SP
1
2require 5;
3package Pod::Simple::PullParserTextToken;
4use Pod::Simple::PullParserToken ();
5@ISA = ('Pod::Simple::PullParserToken');
6use strict;
7
8sub new { # Class->new(text);
9 my $class = shift;
10 return bless ['text', @_], ref($class) || $class;
11}
12
13# Purely accessors:
14
15sub text { (@_ == 2) ? ($_[0][1] = $_[1]) : $_[0][1] }
16
17sub text_r { \ $_[0][1] }
18
191;
20
21__END__
22
23=head1 NAME
24
25Pod::Simple::PullParserTextToken -- text-tokens from Pod::Simple::PullParser
26
27=head1 SYNOPSIS
28
29(See L<Pod::Simple::PullParser>)
30
31=head1 DESCRIPTION
32
33When you do $parser->get_token on a L<Pod::Simple::PullParser>, you might
34get an object of this class.
35
36This is a subclass of L<Pod::Simple::PullParserToken> and inherits all its methods,
37and adds these methods:
38
39=over
40
41=item $token->text
42
43This returns the text that this token holds. For example, parsing
44CZ<><foo> will return a C start-token, a text-token, and a C end-token. And
45if you want to get the "foo" out of the text-token, call C<< $token->text >>
46
47=item $token->text(I<somestring>)
48
49This changes the string that this token holds. You probably won't need
50to do this.
51
52=item $token->text_r()
53
54This returns a scalar reference to the string that this token holds.
55This can be useful if you don't want to memory-copy the potentially
56large text value (well, as large as a paragraph or a verbatim block)
57as calling $token->text would do.
58
59Or, if you want to alter the value, you can even do things like this:
60
61 for ( ${ $token->text_r } ) { # Aliases it with $_ !!
62
63 s/ The / the /g; # just for example
64
65 if( 'A' eq chr(65) ) { # (if in an ASCII world)
66 tr/\xA0/ /;
67 tr/\xAD//d;
68 }
69
70 ...or however you want to alter the value...
71 }
72
73=back
74
75You're unlikely to ever need to construct an object of this class for
76yourself, but if you want to, call
77C<<
78Pod::Simple::PullParserTextToken->new( I<text> )
79>>
80
81=head1 SEE ALSO
82
83L<Pod::Simple::PullParserToken>, L<Pod::Simple>, L<Pod::Simple::Subclassing>
84
85=head1 COPYRIGHT AND DISCLAIMERS
86
87Copyright (c) 2002 Sean M. Burke. All rights reserved.
88
89This library is free software; you can redistribute it and/or modify it
90under the same terms as Perl itself.
91
92This program is distributed in the hope that it will be useful, but
93without any warranty; without even the implied warranty of
94merchantability or fitness for a particular purpose.
95
96=head1 AUTHOR
97
98Sean M. Burke C<sburke@cpan.org>
99
100=cut
101