#!/usr/local/bin/perl -w # creates latex table with outputs of bernplot2.p in it. @n1list = ( 10 , 20 , 30 ) ; @n2list = ( 5 , 15 , 25 ) ; @n1list = ( 3 ) ; @n2list = ( 5 , 15 ) ; $n2alternate = 10 ;# for n2 above this, only use n2 = 0,2,4.. $w = "0.1in" ; # width of each col eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; print '\begin{tabular}{ccc' ; $j = 0 ; foreach $n2 (@n2list) { $j ++ ; if ( $n2 < $n2alternate ) { $cols[$j] = $n2+1 ; $inc[$j] = 1 ; } else {$cols[$j] = ($n2+1)/2 ; $inc[$j] = 2 ; } print "*{$cols[$j]}{p{$w}@{}}c" ; } print "}\n" ; print '% headings of n2 columns' ; $j = 0 ; print "\n & & \n" ; foreach $n2 (@n2list) { $j ++ ; print "& \multicolumn{$cols[$j]}{c}{$n2} & \n" ; } print '\\'."\n" ; print '\\'."\n" ; print "\n" ; print '% numbers for n2 columns' ; $j = 0 ; print "\n & & \n" ; foreach $n2 (@n2list) { $j ++ ; $n = 0 ; for ( ; $n <= $n2 ; $n += $inc[$j] ) { print "& $n " ; } print " & \n" ; } print '\\\\'."\n" ; print '\\\\'."\n" ; $i = 0 ; foreach $N1 (@n1list) { $i ++ ; $j = 0 ; print "$N1 \n" ; for ( $n1 = 0 ; $n1 <= $N1 ; $n1 ++ ) { print " & $n1 & \n" ; $j = 0 ; foreach $N2 (@n2list) { $j ++ ; for ( $n2 = 0 ; $n2 <= $N2 ; $n2 += $inc[$j] ) { print "& \n" ; # insert berntable command here # 14 5:44 bernplot2.p r1=3 n1=10 r2=3 n2=100 offset=2 email=1 $command = "bernplot2.p r1=$n1 n1=$N1 r2=$n2 n2=$N2 email=1" ; print "%% $command \n" ; open ( I , "$command |" ) ; $going = 1 ; $ans = "na" ; while($going && ) { if(/P\s*( p1 > p2 )\s*=\s*(.+)\s+/) { $ans = $1 ; $going = 0 ; } } print "$ans" ; } print " & \n" ; } } } print "\\end{tabular}\n" ; #