
stupeas
Novice
Dec 22, 2006, 6:10 AM
Post #1 of 2
(378 views)
|
|
(RESOLVED)Regex as $string
|
Can't Post
|
|
Why does this work fine: #enter three $ characters. print("Enter 3 \$'s :"); $ans=<STDIN>; chomp ($ans); if ($ans=~m/^(\${3})$/){ print("yes\n"); } But this doesnt: print ("Enter 3 \$'s :"); $ans=<STDIN>; chomp ($ans); $regex='m/^(\${3})$/'; if ($ans=~$regex){ print("correct"); } Ive tried loads of variations such as including the binding operator in the string, appending in the IF statement, different use of quotes, but no joy.. TIA Answer : use $regex=qr/..../;
(This post was edited by stupeas on Dec 22, 2006, 6:53 AM)
|