$pattern = "something"; if ($foo =~ /$pattern/o) { #stuff }