Well, the syntax of lines 11 and 12 isn't quite right. If you're trying to save a regex to a variable for later use, then what you want is:
my $pattern1 = qr/(word)-(spacing):\s*[\d]+px/; # word spacing regexp my $pattern2 = qr/(letter)-(spacing):\s*[\d]+px/; # letter spacing r +egexp
This will compile each regex to that variable.

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:

foreach my $line (@htmlLines) { if(/$pattern1 && $pattern2/) { printHTML(); } else { notFound(); } }
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.

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:

if(/(word)-(spacing):\s*[\d]+px/ && qr/(letter)-(spacing):\s*[\d]+px/)
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.

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.


milkbone - perl/tk instant messaging - it's the only way to fly

In reply to Re: Regexp conundrum by batkins
in thread Regexp conundrum by Tricky

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.