Guys,
I'm wondering if there is a better/faster
way to do it. Here is my current working code.
#!/usr/bin/perl -w
use strict;
my $super = 'AAAAATT';
my $sub = 'AT'; # Returns 1 (True)
#my $sub = 'AAA'; # Returns 1 (True)
#my $sub = 'GGG'; # Returns 0 (False)
print is_subst($super,$sub), "\n";
sub is_subst
{
my ($super,$sub) = @_;
my $sup_len = length $super;
my $sub_len = length $sub;
foreach (my $i = 0; $i<$sup_len; $i++)
{
my $str = substr($super,$i,$sub_len);
if ( $str eq $sub )
{
return 1;
last;
}
}
return 0;
}