> Hi Chris, > Check this if it helps. > > <CODE> > #!\usr\bin\perl -w > use strict; > use Carp; > > > my( $Cell,$CBR,$CDM1,$CDM2,$CDM3,$TFU1,$TFU2,$CCU,$EVM,$TXAMP,$CTRM ) > > =('Cell','CBR','CDM1','CDM2','CDM3','TFU1','TFU2','CCU','EVM','TXAMP','CTRM'); > my $header='HR 17-21 HEH Report'; > > croak "please, specify input file" unless $ARGV[0]; > my $filename=$ARGV[0]; > my($cell,$count)=0; > open my $fh, '<', $filename or croak "ERROR opening $filename: $!"; > open FILE,">",'output.txt' or croak "can't open file:$!"; > while(my $line=<$fh>) {chomp $cell; > if ($line=~/HEH/sixmg){ > ++$count; # NOTE: this might not be > the best way to go in case your $cell values changes > > ($cell=$line)=~s/(?:.*?)CELL\s+([0-9]+)\s+(.+?),.*?HEH$/$1/ixmg; > } > }write FILE; > close FILE or croak"can't close file"; > close $fh or croak"can't close file"; > > > format FILE_TOP= > @|||||||||||||||||||||||||| > $header > @<<<< @<<<< @<<<< @<<<< @<<<< @<<<< @<<<< @<<<< @<<<< @<<<< > @<<<< > $Cell, $CBR, $CDM1 , $CDM2 , $CDM3, $TFU1, $TFU2, $CCU, $EVM, > $TXAMP, $CTRM > > --------------------------------------------------------------------------------------------------------------------------- > . > format FILE= > @<<<<<<<<<< @### > $cell, $count > . > > </CODE> > > Please note the dot in the format 'template'. > > output.txt HR 17-21 HEH Report Cell CBR CDM1 CDM2 CDM3 TFU1 TFU2 CCU EVM TXAMP CTRM --------------------------------------------------------------------------------------------------------------------------- 20 2
-- Tim