#!/usr/local/bin/perl -w # splits a file into C files, one col each. # How to override min and max values with command line $file = "t." ; eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $i=0; while(<>){ $i++; @c = split ( ' ' ) ; if ( $i == 1 ) { $tot = $#c ; $thistot = $#c ; for ( $n = 0 ; $n <= $thistot ; $n ++ ) { $s[$n] = "" ; # } } else { $thistot = $#c ; if ( $thistot != $tot ) { print "eek, $thistot, $tot\n" ;}} for ( $n = 0 ; $n <= $thistot ; $n ++ ) { $s[$n] .= $c[$n] ."\n" ; } } # write out a program for rescaling print "#generated by split.p \n" ; for ( $n = 0 , $m = 1 ; $n <= $thistot ; $n ++ , $m ++ ) { $thisfile = $file.$m ; open ( O , "> $thisfile" ) ; print O $s[$n] ; close ( O ) ; }