Removing the whitespace would match
ju mps over a laz y
in
quick brown fox jumps over a lazy dog
But I assume, that this is not what you want. So, it would be a good idea to convert the whitespace to patterns before you try to match:
sub substr_ignore_whitespace
{
my $string = shift;
my $sub_string = shift;
$sub_string =~ s/\s+/\\s+/g;
return $string =~ /$sub_string/;
}