#!/usr/local/bin/perl # read in file one row at a time, reporting on contents $comments = 0 ; $blank = 0 ; $lastnum = -999 ; $num_lines_same = 0 ; $num_blocks = 0 ; $sep="0"; # replace by preferred separator eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; while ( <> ) { s/^\s*//; # get rid of initial gap on line if ( /^\#/ || /^\%/ ) { $comments ++ ; } else { if("0" eq $sep) { @w=split ; # (/[ \t\n]+/, $_ , $I ; }else{ @w=split($sep, $_) ; } if ( $#w == -1 ) { $blank ++ ; } else { if ( $#w != $lastnum ) { # new block if ( $num_blocks > 0 ) { # report previous block &report () ; } $num_blocks ++ ; $num_lines_same = 0 ; $lastnum = $#w ; } $num_lines_same ++ ; } } } &report () ; if ( $blank + $comments > 0 ) { print "-----------\n$blank blank lines, $comments comments\n" ; } sub report { $lastnum ++ ; print "Block $num_blocks: $num_lines_same lines, $lastnum entries\n" ; }