#! perl 
use File::Basename;
use Pod::ParserText;
use RISCOS::File 'globlist';

$verbose = 1;

$baseout = '/Docs/RISCOS-Library-Docs';
unless (@ARGV) {
    @ARGV = 'pod/*.pod';
    $baseout = '/Docs/'
}
for (reverse globlist @ARGV)
{
    $parser = new Pod::ParserText;
    $base = basename $_, '.pod';
    $out = "$baseout/$base";
    print STDERR "< $_ >$out\n" if $verbose;

    $parser->parse_from_file($_, "$out");
    if (-z $out) {
	if (unlink $out) {
	    print STDERR "Removed zero length $out\n";
	} else {
	    print STDERR "Failed to remove zero length $out: $!\n";
	}
    }
}
