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