1package Pod::Simple::PullParserTextToken; 2use strict; 3use warnings; 4use Pod::Simple::PullParserToken (); 5our @ISA = ('Pod::Simple::PullParserToken'); 6our $VERSION = '3.45'; 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 (Note that starting with Perl v5.8, you can use, e.g., 72 73 my $nbsp = chr utf8::unicode_to_native(0xA0); 74 s/$nbsp/ /g; 75 76 to handle the above regardless if it's an ASCII world or not) 77 } 78 79=back 80 81You're unlikely to ever need to construct an object of this class for 82yourself, but if you want to, call 83C<< 84Pod::Simple::PullParserTextToken->new( I<text> ) 85>> 86 87=head1 SEE ALSO 88 89L<Pod::Simple::PullParserToken>, L<Pod::Simple>, L<Pod::Simple::Subclassing> 90 91=head1 SUPPORT 92 93Questions or discussion about POD and Pod::Simple should be sent to the 94pod-people@perl.org mail list. Send an empty email to 95pod-people-subscribe@perl.org to subscribe. 96 97This module is managed in an open GitHub repository, 98L<https://github.com/perl-pod/pod-simple/>. Feel free to fork and contribute, or 99to clone L<https://github.com/perl-pod/pod-simple.git> and send patches! 100 101Patches against Pod::Simple are welcome. Please send bug reports to 102<bug-pod-simple@rt.cpan.org>. 103 104=head1 COPYRIGHT AND DISCLAIMERS 105 106Copyright (c) 2002 Sean M. Burke. 107 108This library is free software; you can redistribute it and/or modify it 109under the same terms as Perl itself. 110 111This program is distributed in the hope that it will be useful, but 112without any warranty; without even the implied warranty of 113merchantability or fitness for a particular purpose. 114 115=head1 AUTHOR 116 117Pod::Simple was created by Sean M. Burke <sburke@cpan.org>. 118But don't bother him, he's retired. 119 120Pod::Simple is maintained by: 121 122=over 123 124=item * Allison Randal C<allison@perl.org> 125 126=item * Hans Dieter Pearcey C<hdp@cpan.org> 127 128=item * David E. Wheeler C<dwheeler@cpan.org> 129 130=back 131 132=cut 133