Reputation: 21
I am having some issues with matching when i try and implement pre-compiled regex in a Perl script. I have the script working without pre-compiling, and any time I have an express that spans lines, it returns no match when pre-compiling. So for example:
my $regex_partner = qr/<h1 id="PartnerName">(?<partner_name>.*?)<\/h1>/;
$content =~ $regex_partner;
$partner_name = $+{partner_name};
Works fine when pre-compiling, but:
my $regex_web =~ qr/Company Website:.*openWindow[(]'(?<website>http:\/\/.*?)'/s;
$content =~ $regex_web;
$website = $+{website};
returns nothing, but works if i take out the whole pre-compile. It seems any time qr//s is used, it will not work.
help?
Upvotes: 2
Views: 127
Reputation: 164769
You have a typo.
my $regex_web =~ qr/.../s;
That should be:
my $regex_web = qr/.../s;
The former is performing a pattern match against $regex_web
. The latter is assigning the pattern to $regex_web. If warnings were on you'd have gotten a "Use of uninitialized value $regex_web in pattern match" warning.
Unless it's a typo in your post?
Upvotes: 9