Gnuplot-version-functionality into a subroutine. I now do this AFTER

parsing the commandline to allow the script to pass CPAN tests on
machines without gnuplot installed
This commit is contained in:
Dima Kogan 2011-01-29 19:53:17 -08:00
parent 8f365d0521
commit d9d99d3c34

View File

@ -12,19 +12,11 @@ use Text::ParseWords;
our $VERSION = '1.02';
open(GNUPLOT_VERSION, 'gnuplot --version |') or die "Couldn't run gnuplot";
my ($gnuplotVersion) = <GNUPLOT_VERSION> =~ /gnuplot\s*(\d*\.\d*)/;
if(!$gnuplotVersion)
{
print STDERR "Couldn't find the version of gnuplot. Does it work? Trying anyway...\n";
$gnuplotVersion = 0;
}
close(GNUPLOT_VERSION);
my %options;
interpretCommandline(\%options);
my $gnuplotVersion = getGnuplotVersion();
# list containing the plot data. Each element is a reference to a list, representing the data for
# one curve. The first 'point' is a hash describing various curve parameters. The rest are all
# references to lists of (x,y) tuples
@ -270,6 +262,20 @@ OEF
return \%options;
}
sub getGnuplotVersion
{
open(GNUPLOT_VERSION, 'gnuplot --version |') or die "Couldn't run gnuplot";
my ($gnuplotVersion) = <GNUPLOT_VERSION> =~ /gnuplot\s*(\d*\.\d*)/;
if (!$gnuplotVersion)
{
print STDERR "Couldn't find the version of gnuplot. Does it work? Trying anyway...\n";
$gnuplotVersion = 0;
}
close(GNUPLOT_VERSION);
return $gnuplotVersion;
}
sub plotThread
{
while(! $streamingFinished)