Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Pair Tag missing

by ambrus (Abbot)
on May 31, 2005 at 09:55 UTC ( [id://461975]=note: print w/replies, xml ) Need Help??


in reply to Pair Tag missing

Here's my solution.

#!perl use warnings; use strict; sub rfindi (&@) { my $th = $_[0]; for my $i (1 .. @_ - 1) { &$th($_[@_ - $i]) and return @_ - $i - 1; } return; } my @t; my $e = 0; while (local $_ = <>) { while (m(<(/)?(\w+))g) { my $t = uc $2; if (!defined($1)) { push @t, $t; } else { if ($t eq $t[-1]) { pop @t; } elsif (defined(my $i = rfindi { $_[0] eq $t +} @t)) { $e = 1; warn "unclosed ", join(",", @t[$i + 1 +.. @t - 1]), " tags at ", $t, " end tag"; delete @t[$i .. @t - 1]; } else { $e = 1; warn "closing unopened ", $t, " tag"; } } #warn "[$.:$+[0]: @t]\n"; } } @t and do { $e = 1; warn "unclosed ", join(",", @t), " tags at eof"; }; exit $e; __END__

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://461975]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-25 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found