in reply to Re^3: using constants in regex/search
in thread using constants in regex/search

You have copied the NAME value to a variable and used as $NAME.
i have specified a method, which will use the constant NAME itself in the regular expression
use strict; use constant NAME => 'abc'; if ($ARGV[0] =~ /${\NAME}/) { print "match"; };

Replies are listed 'Best First'.
Re^5: using constants in regex/search
by JavaFan (Canon) on Dec 03, 2008 at 10:11 UTC
    You're sure you didn't update your post? I know about the difference between ${NAME} and ${\NAME}, and when replying, I checked to make sure there wasn't a \ there.
      i am updated my post
      Still you can access constant 'abc' in regular expression like ${NAME} without "use strict".
      While using the "use strict", this needs to be escaped.
      "use strict" is important.