my $regex = '\s'; my $string = '\a\s\b'; if ( $string =~ /$regex/ ) { say 'TRUE' } else { say 'FALSE' }; #:FALSE $regex = quotemeta $regex; if ( $string =~ /$regex/ ) { say 'TRUE' } else { say 'FALSE' }; #:TRUE