#!/usr/local/bin/perl

#convert pdf to ps given the list of files to convert as argument

$#ARGV==0 || "Usage: change_to_ps.pl  filelist\n";
$filelist = $ARGV[0];
if ( (! -e $filelist) || (! open FILES, "<$filelist") ) {
    print "Can't open filelist `$filelist': $!\n";
}
while ($line = <FILES>) {
     chomp $line;
     next if ($line =~ /^\s*$/);
     ($pdffile) = split " ", $line;

     $pdffile =~ /(.*).pdf/ || die "Input not a pdf file: $pdffile\n";
     $base = $1;
     `pdf2ps $pdffile $base.ps`;
     if ($?) {
	die "pdf2ps failed for file $pdffile: $!\n";
    }
}
close FILES || die "close failed: $!\n";

