#!/usr/bin/perl -w use strict; my ($tagOpen, $tagClosed, $parseData); open(FILE, "<", 'htmlFile.html') || die "Error reading file: ($!)\n"; $parseData .= $_."\n" while (); close(FILE); my @tags = qw(TITLE AUTHOR H1 H2 P IT); for (@tags) { $tagOpen++ while ($parseData =~ /<$_>/g); $tagClosed++ while ($parseData =~ /<\/$_>/g); error($_, $tagOpen, $tagClosed) unless ($tagOpen == $tagClosed); $tagOpen = $tagClosed = 0; } sub error { my ($tag, $open, $closed) = @_; print "Error found in tag: <$tag> (Open: $open -- Closed: $closed)\n"; return; }