#!/usr/local/bin/perl # usage returns.p w=3 t=0.3 a b c d e filename # where a b c d e are positive integers # causes each line to be split and returned as a series of lines, # with the first a items on line 1, the next b on line 2, etc. # if we run out of a b c , then we go back to a. # only w characters of each field are printed. # t defines a threshold: only numbers with abs above the threshold are printed. $t=-1.0; $l=0; $w=5; $z=0; # get override of variables eg w eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; # get numeric arguments while ( $ARGV[0]=~ /^(\d+)/ ) {$num[$l++]=$1; shift;} # what remains in argv is used as filenames for input $lmax=$l; if($t > 0.0 ) { $spacer = "." x ($w) ; } while( <>){ $l=0; $thisline=0; @orig=split; if($z == 1){ s/\.0/\./g; } if($t > 0.0 ){ s/-0\./-/g; s/0\./\./g; } @fields=split ; for ( $i = 0 ; $i <= $#fields; $i++) { if($t > 0.0 && $orig[$i] < $t && $orig[$i] > (- $t) ){ print $spacer; } else { print substr($fields[$i],0,$w); } print " "; $thisline++; if($thisline==@num[$l]){ print "\n"; $thisline=0; $l++; if($l>=$lmax){$l=0;} } } print "\n"; }