mwunderlich has asked for the wisdom of the Perl Monks concerning the following question:
However, this isn't working as expected. If I remove the lookahead and lookbefore clauses from the regex, it does work. Any ideas why?open (MYFILE, 'RegExTest.txt'); #Init variables $searchTerm = "searchForThis"; $pre = "NotBefore"; $post = "NotAfter"; #Loop through the file while (<MYFILE>) { $line = $_; if($line =~ m/(?<!$pre)$searchTerm?!$post/) {print "Match found: " . $line}; } close(MYFILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using lookaround with variables
by ikegami (Patriarch) on Dec 16, 2008 at 17:51 UTC | |
by graff (Chancellor) on Dec 17, 2008 at 06:19 UTC | |
by ikegami (Patriarch) on Dec 17, 2008 at 07:19 UTC | |
|
Re: Using lookaround with variables
by GrandFather (Saint) on Dec 16, 2008 at 23:10 UTC | |
by mwunderlich (Initiate) on Dec 17, 2008 at 13:19 UTC | |
by mwunderlich (Initiate) on Dec 17, 2008 at 14:34 UTC | |
by GrandFather (Saint) on Dec 17, 2008 at 19:01 UTC | |
by mwunderlich (Initiate) on Dec 17, 2008 at 14:49 UTC |