| Perldoc documentation | Contained in the Perldoc distribution. |
Perldoc::Reader - Reader Class for Perldoc Parsers
package Perldoc::Reader;
Uniform reading interface.
XXX - Should be a mixin for Parsers.
Ingy döt Net <ingy@cpan.org>
Audrey wrote the original code for this parser.
Copyright (c) 2006. Ingy döt Net. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Perldoc documentation | Contained in the Perldoc distribution. |
package Perldoc::Reader; use Perldoc::Base -Base; field 'string'; field 'stringref'; field 'filehandle'; field 'filepath'; sub all { for my $source (qw(string stringref filepath filehandle)) { if (defined $self->{$source}) { my $method = "_all_$source"; return $self->$method(); } } die "No input to read"; } sub _all_string { return $self->string; } sub _all_stringref { return ${$self->stringref}; } sub _all_filepath { my $filepath = $self->filepath; open my $input, $filepath or die "Can't open '$filepath' for input:\n$!"; local $/; return <$input> } sub _all_filehandle { my $filehandle = $self->filehandle; local $/; return <$filehandle>; }