#!/usr/bin/perl use strict; my $cur = "\$foo"; my $after = "This is a \$foo test"; print "Match: '$after' contains '$cur'\n" if ($after =~ /\Q$cur\E/);