■
まとめりゃいいじゃん、と思ったので、まとめた。
あー、そんなことより、課題やれ、って感じだよなぁ。
#! /usr/bin/perl use strict; use warnings; my $usage = "usage: $0 data_filename [tail] [sleep_time]"; my $datafile = shift @ARGV or die "$usage\n"; my $tail = shift @ARGV || 10; my @tail = (); my $sleep_time = shift @ARGV || 0; open DATA, "< $datafile" or die "can't open $datafile\n"; open GNUPLOT, "| gnuplot" or die "can't open gnuplot\n"; select( ( select(GNUPLOT), ( $| = 1 ) )[0] ); print GNUPLOT "set xrange [-1.6e11:1.6e11]\n", "set yrange [-1.6e11:1.6e11]\n", "set nokey\n"; while( <DATA> ){ next if /^\#/; my( $x, $y ) = /^([\d.e+-]*)\t([\d.e+-]*)$/ or die; print GNUPLOT "plot '-' ps 2 pt 3, '-' ps 3 pt 5, '-' pt 2\n"; # '(0,0)`, `(x,y)`, `(x',y'),(x'',y``),,,' print GNUPLOT "0\t0\nend\n"; print GNUPLOT "$x\t$y\nend\n"; print GNUPLOT "0\t0\n" unless @tail; print GNUPLOT $_->[0], "\t", $_->[1], "\n" for @tail; print GNUPLOT "end\n"; push @tail, [ $x, $y ]; shift @tail if( @tail > $tail ); # sleep $sleep_time; select undef, undef, undef, $sleep_time; } sleep 10; close GNUPLOT; close DATA;
sleepなメモ。
http://d.hatena.ne.jp/dasm/20041219#c
JEDのperl、v5.8.2だそうだけど、Time::HiResが入ってないっぽい。なんで?