home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _9f03ce330876cda1222c303386303362 < prev    next >
Text File  |  2004-06-01  |  2KB  |  91 lines

  1.  
  2. # This class is just a hack to act as a "formatter" for
  3. # actually unformatted Pod.
  4. # Note that this isn't the same as just passing thru whatever
  5. # we're given -- we pass thru only the pod source, and suppress
  6. # the Perl code (or whatever non-pod stuff is in the source file).
  7.  
  8.  
  9. require 5;
  10. package Pod::Perldoc::ToPod;
  11. use strict;
  12. use warnings;
  13.  
  14. use base qw(Pod::Perldoc::BaseTo);
  15. sub is_pageable        { 1 }
  16. sub write_with_binmode { 0 }
  17. sub output_extension   { 'pod' }
  18.  
  19. sub new { return bless {}, ref($_[0]) || $_[0] }
  20.  
  21. sub parse_from_file {
  22.   my( $self, $in, $outfh ) = @_;
  23.  
  24.   open(IN, "<", $in) or die "Can't read-open $in: $!\nAborting";
  25.  
  26.   my $cut_mode = 1;
  27.   
  28.   # A hack for finding things between =foo and =cut, inclusive
  29.   local $_;
  30.   while (<IN>) {
  31.     if(  m/^=(\w+)/s ) {
  32.       if($cut_mode = ($1 eq 'cut')) {
  33.         print $outfh "\n=cut\n\n";
  34.          # Pass thru the =cut line with some harmless
  35.          #  (and occasionally helpful) padding
  36.       }
  37.     }
  38.     next if $cut_mode;
  39.     print $outfh $_ or die "Can't print to $outfh: $!";
  40.   }
  41.   
  42.   close IN or die "Can't close $in: $!";
  43.   return;
  44. }
  45.  
  46. 1;
  47. __END__
  48.  
  49. =head1 NAME
  50.  
  51. Pod::Perldoc::ToPod - let Perldoc render Pod as ... Pod!
  52.  
  53. =head1 SYNOPSIS
  54.  
  55.   perldoc -opod Some::Modulename
  56.  
  57. (That's currently the same as the following:)
  58.  
  59.   perldoc -u Some::Modulename
  60.  
  61. =head1 DESCRIPTION
  62.  
  63. This is a "plug-in" class that allows Perldoc to display Pod source as
  64. itself!  Pretty Zen, huh?
  65.  
  66. Currently this class works by just filtering out the non-Pod stuff from
  67. a given input file.
  68.  
  69. =head1 SEE ALSO
  70.  
  71. L<Pod::Perldoc>
  72.  
  73. =head1 COPYRIGHT AND DISCLAIMERS
  74.  
  75. Copyright (c) 2002 Sean M. Burke.  All rights reserved.
  76.  
  77. This library is free software; you can redistribute it and/or modify it
  78. under the same terms as Perl itself.
  79.  
  80. This program is distributed in the hope that it will be useful, but
  81. without any warranty; without even the implied warranty of
  82. merchantability or fitness for a particular purpose.
  83.  
  84. =head1 AUTHOR
  85.  
  86. Sean M. Burke C<sburke@cpan.org>
  87.  
  88. =cut
  89.  
  90.