#!/usr/bin/perl use warnings; $input_data = @ARGV[0]; $output_data = @ARGV[1]; $h2_flag = 0; $h3_flag = 0; open(INFILE,"$input_data") || die "cannot open input file : $infile"; open(OUTFILE,">$output_data") || die "cannot open temporary output file : $output_data"; $/=undef; # Process error data to rectify the error records in massaged data while () { $data = $1; if ($data =~ m/(.*)/) { $h2_flag++; }elsif ($data =~ m/(.*)/) { $h3_flag++; } if ($h2_flag == 1) { if ($data =~ m/(.*)/) { $head_data = $1; $head_data =~ s/.*)/) { $head_data = $1; $Case_No = $head_data = s/(<.*>)(.*)/$2/; $Case_No = $head_data; $date = $head_data; $h2_flag = 0; }elsif ($h3_flag == 1) { print "PRINT"; $h3_flag = 0; } } print OUTFILE $_; # Output the contents of $_ to # output file } # Close the INFILE and OUTFILE. close(INFILE); close(OUTFILE);