#!/usr/bin/perl # https://perlmonks.org/?node_id=1218306 use strict; use warnings; my $a = 'TTTATTT'; my $b = 'TTTTTTT'; my $c = 'TBTTTTT'; print "compare $a to $b, difference is ", $a =~ s/[$b]+//gr, $b =~ s/[$a]+//gr, "\n"; print "compare $b to $c, difference is ", $b =~ s/[$c]+//gr, $c =~ s/[$b]+//gr, "\n"; #### compare TTTATTT to TTTTTTT, difference is A compare TTTTTTT to TBTTTTT, difference is B