#!/usr/bin/perl use warnings; use strict; my $A = 'ATGGAGTCGACGAATTTGAAGAAT'; my $B = 'xxxxxxATGGAGyxxxTCGAzxxxxCGAATTTGAAxxwGAAT'; my @A = split //, $A; my $Are = '^(.*)' . join('(.*)', @A) . '(.*)$'; my @introns = ($B =~ m/$Are/); if (!@introns) { die "There was no possible way to match the input."; } foreach (0..$#introns) { print "$_: $introns[$_] $A[$_]\n"; }