use constant NAME => "abc"; # read some user input my $input = $ARGV[0]; # I need to check if the input string contains my constant # Something like the following is what I need: if ($input =~ /NAME/) { print "Matched!"; } #### my $name = NAME; if ($input =~ /$name/) { ... }