#!/usr/bin/perl

######################################################################
#
# A sample PseudoPod to text converter script that uses
# Pod::PseudoPod::Text.
#
# usage:
#
# ./pod2txt filename1.pod filename2.pod
#
# Will produce one text file for each pod file passed in.
#
#   filename1.txt
#   filename2.txt
#
######################################################################

use strict;
use lib "../lib"; # delete this line
use Pod::PseudoPod::Text;

foreach my $file (@ARGV) {
	my $parser = Pod::PseudoPod::Text->new();

	$file =~ /(\w+)\.pod$/;     # Text output goes to the current working 
	my $outfile = $1 . '.txt'; # directory not the source directory.

	open TXTOUT, ">$outfile" or die "Can't write to $outfile: $!";
	$parser->output_fh(*TXTOUT);

	$parser->no_errata_section(1); # don't put errors in doc output
	$parser->complain_stderr(1);   # output errors on STDERR instead

	if (-e $file) {
		$parser->parse_file($file);
	} else {
		die "Unable to open file\n";
	}
	close TXTOUT;
}

exit;
