Debian Codegraph @

wtools/tace2table

raw
1 #!/usr/local/bin/perl
2 #
3 # tace2table
4 #
5 # tace dumps tables with ; separating the fields.
6 #
7 # Typically : "E77B4";;"95-06-08";;;;
8 #
9 # Convert ;; to ;""; so don't lose fields when split
10 #
11 # Gos - Tue Jul 18 15:54:27 1995
12 # $Id: tace2table,v 1.1 1995/07/18 16:00:57 rd Exp $
13
14 while ( <> ) {
15 s/;;/;"";/g ; # Have to do it twice...
16 s/;;/;"";/g ;
17 tr /"//d ;
18 @lines[ $n++ ] = $_ ; # Keep a copy for later.
19 @fields = split ( /;/ ) ;
20 for ( $i = 0 ; $i < @fields ; ++$i ) {
21 $length = "".split (//, $fields[ $i ] ) ;
22 $size[ $i ] = $length > $size[ $i ] ? $length : $size[ $i ] ;
23 }
24 }
25
26 foreach ( @lines ) {
27 @fields = split ( /;/ ) ;
28 for ( $i = 0 ; $i < @fields ; ++$i ) {
29 $length = "".split (//, $fields[ $i ] ) ;
30 $pads = " " x ( $size[ $i ] - $length +2 ) ;
31 print $fields[ $i ], $pads ;
32 }
33 print "\n" ;
34 }