while () { $_ = clean_line($_); if ($_ =~ /\*+/) { $_ =~ s/\*+//; #remove asterisk only rows; $count++; #the asterisk line only happens once per record, } #so we can use it to count records. 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. } ## ## clean_line() ## ## Argument: $line (string) - Line from the file that needs cleaning ## ## Returns: string - cleaned-up line ## ## Clean_line() returns the $line minus leading and ## trailing whitespace, headers, etc. ## sub clean_line { my $line = shift; #remove the leading and trailing whitespace $line =~ s/^\s*(.*?)\s*$/$1/; tr/\n\r³//; #remove all carriage returns; s/.+ : //; #remove the header information; }