in reply to 2D string array

The error is on line 16 of your script.

Also see How (Not) To Ask A Question.

My approach would be:

my $matches = $left ^ $right; $matches =~ s/(.)/$1 eq "\0" ? '*' : "_" /eg;