#!/usr/bin/perl -w open FILE, "file.txt" or die $!; my $line_num = 0; my $FLAG = 0; my @custnum; my @payment; my @names; my @cknum; my @errors; while (my $line = ) { $line_num++; chomp($line); my $index = substr($line, 0, 5); if ($FLAG == 1) { $line=~/CUST#:.+?(\w.+)PMT\$:\s+(.+)\s/; if (defined $1 && defined $2) { push(@custnum, $1); push(@payment, $2); } else { push(@errors, "Error at line ".$line_num."\n\t".$line."\n"); } $FLAG = 0; } if ($index eq "REMIT") { # Catch a line to extract info from. Then place flag for next line $line=~/TTER:\s(.+?)\s+CK#:.+?([1-9].+)\sCK/; if (defined $1 && defined $2) { $name = $1; push(@names, $1); push(@cknum, $2); $FLAG = 1; } else { if (!defined $2) { #Place bogus cknum if emtpy push(@cknum, "1234"); push(@names, $name); $FLAG = 1; } else { push(@errors, "Error at line ".$line_num."\n\t".$line."\n"); } } } } open RESULT, ">output.txt"; open ERROR, ">error.txt"; for ($i=0;$i