sub compare_files($$$) { my $FH1 = shift; my $FH2 = shift; my $OUTPUT_FH = shift; my @FILE1_ARRY = <$FH1>; my @FILE2_ARRY = <$FH2>; my $CMPR_ARRY_REF = \@FILE1_ARRY; my @CMPR_ARRY = @{$CMPR_ARRY_REF}; my $CMPR_ARRY_NUMBER = 1; if ($#FILE1_ARRY > $#FILE2_ARRY) { print "FILE 1 is larger than FILE 2\n"; print $OUTPUT_FH "FILE 1 is larger than FILE 2\n"; } elsif ($#FILE1_ARRY < $#FILE2_ARRY) { print "FILE 1 is smaller than FILE 2\n"; print $OUTPUT_FH "FILE 1 is smaller than FILE 2\n"; $CMPR_ARRY_REF = \@FILE2_ARRY; @CMPR_ARRY = @{$CMPR_ARRY_REF}; $CMPR_ARRY_NUMBER = 2; } else { print "FILE 1 is the same size as FILE 2\n"; print $OUTPUT_FH "FILE 1 is the same size as FILE 2\n"; } print "*"x70,"\n"; print $OUTPUT_FH "*"x70,"\n"; for(my $iter = 0; $iter <= $#CMPR_ARRY; $iter++) { if ( $CMPR_ARRY_NUMBER == 1 ) { print "END OF FILE 2, BUT NOT FILE 1. STOPPING COMPARE AT LINE ".($iter+1)." OF FILE 1\n" if ($iter > $#FILE2_ARRY); print $OUTPUT_FH "END OF FILE 2, BUT NOT FILE 1. STOPPING COMPARE AT LINE ".($iter+1)." OF FILE 1\n" if ($iter > $#FILE2_ARRY); last if ($iter > $#FILE2_ARRY); if ( quotemeta($CMPR_ARRY[$iter]) eq quotemeta($FILE2_ARRY[$iter]) ) { print $OUTPUT_FH "Line ".($iter+1)." matches between both files\n"; } else { print $OUTPUT_FH "Line ".($iter+1)." does NOT match between both files\n"; } } else { print "END OF FILE 1, BUT NOT FILE 2. STOPPING COMPARE AT LINE ".($iter+1)." OF FILE 2\n" if ($iter > $#FILE1_ARRY); print $OUTPUT_FH "END OF FILE 1, BUT NOT FILE 2. STOPPING COMPARE AT LINE ".($iter+1)." OF FILE 2\n" if ($iter > $#FILE1_ARRY); last if ($iter > $#FILE1_ARRY); if ( quotemeta($CMPR_ARRY[$iter]) eq quotemeta($FILE1_ARRY[$iter]) ) { print $OUTPUT_FH "Line ".($iter+1)." matches between both files\n"; } else { print $OUTPUT_FH "Line ".($iter+1)." does NOT match between both files\n"; } } } print "*"x70,"\nCompare Complete."; print $OUTPUT_FH "*"x70,"\nCompare Complete."; } #### compare_files($FH1,$FH2,$OUTPUT_FH);