HListG beta ver.
HListの結果をgnuplotで表示するためのスクリプト。やっつけなかんじでつくってみた。
#! /usr/bin/perl use Getopt::Std; my %option; my $numstate = 0; getopts("n:h", \%option); if ( exists $option{n} ){ if ( defined $option{n} ){ $numstate = $option{n}; }else{ &usage(); } } if ( exists $option{h} ){ &usage(); } &usage() if ( $#ARGV != 0 ); # バイナリで読んでもいいけど面倒なのでHListで読む open (IN,"HList $ARGV[$#ARGV] |"); @hlist=<IN>; close IN; my $counter = 0; # 該当箇所を探す for ( $i=1; $i<=$#hlist; $i++){ if ( $hlist[$i] =~ /:/ ){ $counter = $counter+1; } if ( $counter == $numstate+1){ last; } } # データを整形する my $data = ""; for ( ; $i<=$#hlist; $i++){ $data = $data.$hlist[$i]; if ( $hlist[$i+1] =~ /:/ ){ last; } } $data =~ s/^[0-9]+:\ +//; $data =~ s/\n*\ +/\n/g; # gnuplotでプロット @name = split(/\//, $ARGV[$#ARGV]); open (OUT,">/tmp/HListG_$name[$#name]"); print OUT $data; close OUT; open (GP, "| gnuplot -persist" ) or die "no gnuplot"; print GP "plot \"/tmp/HListG_$name[$#name]\" w l\n"; close GP; system("rm /tmp/HListG_$name[$#name]"); sub usage(){ print <<"_EOF_"; usage: HListG [option] INPUT_FILE options: Default -h \# show help -n numstate [0] _EOF_ exit; }