home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / pom2.bat < prev    next >
Encoding:
DOS Batch File  |  2003-11-12  |  2.7 KB  |  124 lines

  1. @rem = '--*-Perl-*--
  2. @echo off
  3. if "%OS%" == "Windows_NT" goto WinNT
  4. perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
  5. goto endofperl
  6. :WinNT
  7. perl -x -S %0 %*
  8. if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
  9. if %errorlevel% == 9009 echo You do not have Perl in your PATH.
  10. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
  11. goto endofperl
  12. @rem ';
  13. #!/usr/bin/perl -w
  14. #line 15
  15. #
  16. # This program implements a simple translator to convert POD
  17. # to HTML, Text, or back to POD again (e.g. for normalising a 
  18. # document).  You can easily extend it to work with any other
  19. # view modules you create which convert POD to different formats
  20. # or in different styles.
  21. #
  22. # Written by Andy Wardley <abw@kfs.org>.   This is free software.
  23. #
  24.  
  25. use Pod::POM;
  26. use File::Basename;
  27.  
  28. my $PROGRAM = 'pom2';
  29. my $program = basename($0);
  30. my $format;
  31. my $views = {
  32.     pod  => 'Pod',
  33.     text => 'Text',
  34.     html => 'HTML',
  35. };
  36.  
  37. die usage() if grep(/^--?h(elp)?$/, @ARGV);
  38.  
  39. if ($program =~ /^$PROGRAM(.+)$/) {
  40.     $format = $1;
  41. }
  42. else {
  43.     $format = shift 
  44.     || die usage('no output format specified');
  45. }
  46.  
  47. my $file = shift 
  48.     || die usage('no filename specified');
  49.  
  50. $format = lc $format;
  51. my $view = $views->{ $format } 
  52.     || die usage("invalid format '$format', try one of: " 
  53.             . join(', ', keys %$views));
  54.  
  55. $view = "Pod::POM::View::$view";
  56. Pod::POM->default_view($view)
  57.     || die "$Pod::POM::ERROR\n";
  58.  
  59. my $parser = Pod::POM->new( warn => 1 )
  60.     || die "$Pod::POM::ERROR\n";
  61.  
  62. my $pom = $parser->parse_file($file)
  63.     || die $parser->error(), "\n";
  64.  
  65. print $pom;
  66.  
  67.  
  68. #------------------------------------------------------------------------
  69.  
  70. sub usage {
  71.     my $msg = shift || '';
  72.  
  73.     if ($program =~ /^$PROGRAM$/) {
  74.     $program = "pom2 format";
  75.     }
  76.     
  77.     return <<EOF;
  78. ${msg}
  79. usage: $program file
  80. EOF
  81. }
  82.  
  83. __END__
  84.  
  85. =head1 NAME
  86.  
  87. pom2 - convert POD to Text, HTML, etc., with Pod::POM
  88.  
  89. =head1 SYNOPSIS
  90.  
  91.     pom2 text MyFile.pm > MyFile.txt
  92.     pom2 html MyFile.pm > MyFile.html
  93.     pom2 pod  MyFile.pm > Myfile.pod
  94.  
  95. =head1 DESCRIPTION
  96.  
  97. This script uses Pod::POM to convert a Pod document into text,
  98. HTML, back into Pod (e.g. to normalise a document to fix any 
  99. markup errors), or any other format for which you have a view
  100. module.
  101.  
  102. =head1 AUTHOR
  103.  
  104. Andy Wardley E<lt>abw@kfs.orgE<gt>
  105.  
  106. =head1 VERSION
  107.  
  108. This is version 0.2 of pom2.
  109.  
  110. =head1 COPYRIGHT
  111.  
  112. Copyright (C) 2000, 2001 Andy Wardley.  All Rights Reserved.
  113.  
  114. This module is free software; you can redistribute it and/or
  115. modify it under the same terms as Perl itself.
  116.  
  117. =head1 SEE ALSO
  118.  
  119. For further information please see L<Pod::POM>.
  120.  
  121.  
  122. __END__
  123. :endofperl
  124.