#!/usr/bin/perl require("cgi-lib.pl"); &ReadParse; #This program prints data from a flat file. The file can be compressed. #By default it will print the first 10 lines of data, but you can #print other ranges. #Written by Paul H. Bern 26JAN01 print "\nEnter file name: "; $f=<>; chomp($f); print "\nEnter From column to print: "; $v=<>; chomp($v); print "\nEnter To column to print: "; $vv=<>; chomp($vv); $vvv = $vv - $v + 1; print "\nEnter lines to print[1 10]: "; $nl=<>; chomp($nl); print "\n\n"; if($f =~ /gz$|Z$/i) { open(inp,"zmore $f|") or die "file not found"; $fl=2; if($nl eq "") { $s=2; $e=11; } if($nl ne ""){ @nl=split(/ /,$nl); $s=@nl[0]+1; $e=@nl[1]+1; } } if($f !~ /gz$|Z$|z$|zip$/i) { open(inp,"$f") or die "file not found"; $fl=1; if($nl eq "") { $s=1; $e=10; } if($nl ne ""){ @nl=split(/ /,$nl); $s=@nl[0]; $e=@nl[1]; } } print "Columns $v-$vv \n\n"; while () { $l = $.; if($. >= $s && $. <= $e) { if($fl==2) {$l=$.-1;} $b = $v-1; $_ =~ s/.{$b}(.{$v,$vvv}).*\n/$1/; print "$_ <- $l\n"; } } print "\n\n"; if($. == $e) {print "\n\nHit cntrl-c\n\n";} close(inp);