On Oct 27, [EMAIL PROTECTED] ([EMAIL PROTECTED]:

Brian:  Assign each line to the $_ variable and try this to get the number of
Brian:  instances of < and >
Brian:
Brian:  The match operator works on $_ by default. If you match on < or > globally
Brian:  and assign it to an array like so:
Brian:
Brian:  @rights = m/\</g;
Brian:  @lefts = m/\>/g;
Brian:
Brian:  You are left with arrays that contain all the matches. Now all you need to
Brian:  do is count the number of elements in each array like so:
Brian:
Brian:  $number_of_rights = $#rights;
Brian:  $number_of_lefts = $#lefts;
Brian:
Brian:  Then compare them:
Brian:
Brian:  if ($number_of_rights != $number_of_lefts)
Brian:  {
Brian:          ## scream here!!
Brian:  }



Great!  That works.  But I was looking to get a little trickier with it.


If I had:
<DT <A HREF="http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html"; 
ADD_DATE="897592292" LAST_VISIT="982769648" LAST_MODIFIED="982769648" 
ID="rdf:#$rsy5Z">PERL FAQ</A>

I wanted it to scream when it reached the 2nd <  ; stopping the pattern
matching from continuing any further.  Is that possible, or would
something more complex be needed?

If it's too complex, I'll just with what I have for now.


Thanks
 Birl

Please do not CC me responses to my own posts.
I'll read the responses on the list.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to