perl 和 gnuplot

#!/usr/bin/perl

use strict;
use FileHandle;
use File::Temp qw/ tempfile tempdir /;

my ($fh, $filename) = tempfile(DIR => './', UNLINK => 1);
foreach my $x (-50 .. 50){
    print $fh $x/5,"  ",sin($x/5),"\n";
}
$fh->flush();

open PLOT,"| gnuplot -persist";
PLOT->autoflush(1);
print PLOT << "gnuplot_Commands";
plot '$filename' with line
pause 1

plot cos(x)
gnuplot_Commands
close PLOT;


凑出来的,看上去还比较简单,以后再处理数据的时候要考虑画个图出来了。

08年前,再发上一贴,呵呵。