$text =~ s/\s//g; # or tr///, etc do_something( $text ) if $text =~ /your_pattern_here/;