in reply to compare two data sets (matrix)

This script shows matching lines with their line numbers:
use strict; use 5.010; sub file_to_arr { my $fil_name = shift; open my $fh,$fil_name or die qq(Some error when opening file "$fil_name": $!); my $rslt; while (<$fh>) { s/[\n\r]//g; # removing CR and LF symbols next unless $_; # skipping empty lines push @$rslt,[split /\s+/]; } return $rslt; } my ($arr1,$arr2) = (file_to_arr('3.txt'),file_to_arr('4.txt')); for (my $i = 0; $i<=$#$arr1; $i++) { if (@{$arr1->[$i]} ~~ @{$arr2->[$i]}) { printf "%s: %s\n", $i+1, "@{$arr1->[$i]}"; } }