in reply to Catching expressions from a file
Two problems stand out to me:
First:
if(@Functions =~ /$expr/gi)needs to be
if (grep { /$expr/i } @Functions)This will test each member of @Functions with your regular expression. What you wrote will compare the length of @Functions to your expression.
Also, the g in /gi is not needed.
So, the whole line is better written as
next if (grep { /$expr/i } @Functions);Then:
if($1 =~ ""){goto cont1;}Two things: The value of $1 is not guaranteed after a failed reg ex match. Also, you have an intervening, unrelated, reg ex match. The following should work:
next unless ($exp);Now, a simple thing:
open (file1, "<$filename") or goto cont2;is better written as
open (file1, "<$filename") or return;If the open fails, there's nothing to close.
I hope this helps.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Catching expressions from a file
by GrandFather (Saint) on Jul 26, 2014 at 02:33 UTC |