⭐ in reply to Compare two strings of same length, character-by-character
#!/usr/bin/perl use strict; # https://www.perlmonks.org/?node_id=11155923 use warnings; use feature 'bitwise'; my $str1='LFGSLSIIVAHHM'; my $str2='LFGSLSIIVSHHM'; print +($str1 ^. $str2) =~ tr/\0//, " characters are the same\n";
Outputs:
12 characters are the same
|
---|