in reply to Regexp conundrum
This will compile each regex to that variable.my $pattern1 = qr/(word)-(spacing):\s*[\d]+px/; # word spacing regexp my $pattern2 = qr/(letter)-(spacing):\s*[\d]+px/; # letter spacing r +egexp
I don't really know why you have a sub inside a while loop, or why there's a for loop inside that sub. I would recommend just using one big for loop, like so:
You don't need the while loop (which wasn't doing what you wanted anyway - it would have looped forever), and you don't really need the extra sub anyway.foreach my $line (@htmlLines) { if(/$pattern1 && $pattern2/) { printHTML(); } else { notFound(); } }
The code in the if clause is also not likely to do what you want. Personally, I would recommend avoiding compiled regexes (like those on lines 11 and 12). So take out lines 11 and 12 and replace the if clause with this:
The printHTML function is getting called on every iteration through the loop, which is probably unnecessary. The notFound sub is superfluous, but won't cause you any problems.if(/(word)-(spacing):\s*[\d]+px/ && qr/(letter)-(spacing):\s*[\d]+px/)
To be brutally honest, this code doesn't make much sense. Could you explain exactly what you're trying to do? This way, we can help you get where you're trying to go.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regexp conundrum
by Tricky (Sexton) on Aug 22, 2003 at 09:26 UTC |