What I think you are actually saying is that you want to know when you
encounter two <'s or two >'s in a row You then want the program to alert and
exit. The following accomplishes this. Apologies if I misunderstood.
-ZO
-----
#!/usr/bin/perl
use warnings;
use strict;
my $count;
my $text = '<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>';
for my $pos(0 .. length($text)-1) {
$count++ if substr($text, $pos, 1) eq '<';
$count-- if substr($text, $pos, 1) eq '>';
die "Imbalanced tags at position $pos\n" if abs $count > 1;
}
print "Tags are balanced!\n"
"S.A. Birl" <[EMAIL PROTECTED]> wrote in message ...
> 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?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>