Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
How do I stop the "[" in $Name from being interpreted as a regular expression control character? Remember... $Name is really read from a file so I can't escape it. I need to modify the search, not the source data. Regards, Steve$Name = "[A"; $SearchInHere = "FredJimBert"; if ($SearchInHere =~/$Name/) { DoSomething(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Stop variable expansion
by choroba (Cardinal) on Mar 18, 2021 at 21:30 UTC | |
by SteveDC (Initiate) on Mar 19, 2021 at 03:20 UTC | |
by AnomalousMonk (Archbishop) on Mar 19, 2021 at 06:05 UTC | |
by SteveDC (Initiate) on Mar 19, 2021 at 03:24 UTC | |
by GrandFather (Saint) on Mar 19, 2021 at 03:38 UTC | |
|
Re: Stop variable expansion
by haukex (Archbishop) on Mar 18, 2021 at 21:29 UTC | |
by SteveDC (Initiate) on Mar 19, 2021 at 03:26 UTC |