#!/usr/bin/perl 

use strict;
use warnings;

use basic;

my ($figs_dir, @files, $file, $dot_command, $format_command, @formats,
    $format, $dot_file, $format_file, $retval, %params);

@formats = ("png");

$figs_dir = ".";
opendir(FIGS_DIR, $figs_dir) or die("Cannot open directory $figs_dir: $!");
@files = readdir(FIGS_DIR);

foreach $file (@files)
  {
    next unless ($file =~ m/dot$/);
    print("File is $file.\n");
    $params{FILE_BASE_PREFIX} = "laid-out-";
    $params{FILE_EXTENSION} = ".dot";
    $dot_file = create_file_name($file, %params);
    $dot_command = "neato $file > $dot_file";
    $retval = system($dot_command);
    die("\"$dot_command\" returned $retval.\n") if $retval;
    foreach $format (@formats)
	 {
	   $params{FILE_EXTENSION} = ".$format";
	   $format_file = create_file_name($file, %params);
#	   $format_file = "laid-out-$file.$format";
	   $format_command = "neato -T$format $dot_file > $format_file";
	   $retval = system($format_command);
	   die("\"$format_command\" returned $retval.\n") if $retval;
	 }
  }



__END__

