#!/usr/perl/bin -w my @coswork_test; my @func_test; my $count = 0; open (REPORT, "cpuf.rpt") || die "Can't open CPUF.RPT: $!\n"; open (OUTFILE, ">cpuf.med") || die "Can't open CPUF.OUT: $!\n"; while () { s/^ +//; #remove the leading whitespace; s/\r//; #remove all carriage returns; s/ +$//; #remove the trailing whitespace; s/.+ : //; #remove the header information; if ($_ =~ /\*+/) { $_ =~ s/\*+//; #remove asterisk only rows; $count++; #the asterisk line only happens once per record, } #so we can use it to count records. s/\n/³/; if (($_ =~ /Cosmetics/)||($_ =~ /Function/)) { #look for _X_Pass or _X_Fail $_ =~ s/.+_X_(.{4}).*/$1/; #make it Pass or Fail } print OUTFILE "$_"; #print the line to the intermediate file. } close OUTFILE; open (INFILE, "cpuf.med") || die "Can't open CPUF.MED $!\n"; open (OUTFILE, ">cpuf.out") || die "Can't open CPUF.OUT $!\n"; #now, print the headers: print OUTFILE "DATE³QC SPEC.³REPAIR NUM³TECHNICIAN³CPU MODEL³CPU ASSET NUM³COSMETICS ". "WORKMANSHIP TEST³FUNCTIONALITY TEST³FAILURE DETAIL\n"; #and the information: while () { s/.{129}//; s/³{2}/\n/g; #replace ³PassFail³ with ³Pass³Fail³, and Fail with Fail³³ s/³Fail³/³Fail³³/g; s/³PassFail³/³Pass³Fail³/g; s/Failure Detail - //g; print OUTFILE "$_"; }