my $pattern = join '\s*', split //, "whatever"; while (<>) { print if /$pattern/; }