$page = join "", @prep; # since the lines are in an array
if (my ($tag) = $page =~ m//) {
# call the appropriate sub based on the tag
if ($tag eq 'a') {
suba; exit;
} elsif ($tag eq 'b') {
subb; exit;
} # ...etc...
}
####
my $subs = {
a => \&suba,
b => \&subb,
# etc.
}
if ($subs->{$tag}) {
$subs->{$tag}->();
} else {
warn "Unknown tag <$tag> in file <$prepage>\n";
}
####
my $tag;
while () {
if (m//) {
$tag = $1;
last; # assuming there is only one tag in each file
}
}
close ;
# proceed to call the tag handler