my $intersect = substr($left,-$length); if ( $right =~ /^$intersect/ ) { print "matched again!\n"; }