Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I need to search for the phrase: !CCSD(T) STATE 1.1 ENERGY in a text file.
simply enough, I can use the matching operator as such:
$_ =~ m/'!CCSD\(T\) STATE 1.1 ENERGY'/
The string is matched and all is well.
The complication comes in because I need to read the phrase from a different text file. Once the phrase is parsed from the text, I store it in a variable called $flag.
I, then, use the matching operator this way:
$_ =~ m/$flag/
The string never matches.
I have tried every conceivable combination of quotes and backslashes without any luck. How can I get this rather seemingly routine thing to work?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: string matching
by FunkyMonk (Chancellor) on Sep 21, 2007 at 18:27 UTC | |
by Anonymous Monk on Sep 21, 2007 at 18:35 UTC | |
Re: string matching
by kyle (Abbot) on Sep 21, 2007 at 19:09 UTC | |
Re: string matching
by Anno (Deacon) on Sep 21, 2007 at 21:26 UTC |