my $pattern = "\\" . $cur; if ($after =~ /$pattern/) { do something; }