S.A. Birl wrote:
Wondering if it's possible to have 2 counters that would keep track
of the number of < and > encountered.

Im looking to see if there's a balance of < and >, and scream as soon
as there isnt a balance.

So given the above bookmark, I know that there's 3 <  and  3 > and
the pattern is basically <><><> and not <<>> or >><, etc.

Assuming that you are actually not interested in *counting* them, this is one approach:

  print "Oops!\n" unless $string =~ /^[^<>]*(?:(?:<[^<>]*>)*[^<>]*)*$/;

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
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