G'day epimenidecretese,
I'm not completely sure what you're after.
A small, representative sample of data and expected output would have helped.
If by "pile up all the code" you mean process all of your HTML files in a single run, then yes, getting a frequency count of all the tags in all the files "is possibile in a few lines of code".
Here's pm_1082082_html_tag_count.pl:
#!/usr/bin/env perl -l
use strict;
use warnings;
my %tags;
while (<>) {
++$tags{$1} while /<(?!\/)([^ >]+)/g;
}
print "$_\t$tags{$_}" for sort { $tags{$b} <=> $tags{$a} } keys %tags;
Here's some dummy input data.
You can view those in a browser if you want: they render OK but they're not very interesting.
$ ls -l pm_1082082_*.html
-rw-r--r-- 1 ken staff 237 13 Apr 12:13 pm_1082082_1.html
-rw-r--r-- 1 ken staff 237 13 Apr 12:12 pm_1082082_2.html
$ cat pm_1082082_1.html
<h1 id="H-1">Heading 1</h1>
<p class="sub-heading">
Some <strong>bold</strong> and <em>italic</em> text.</p>
<h2 id="H-1-2">Heading 1.2</h2>
<p>Para1 (1.2.1)</p><p>Para2 (1.2.2)</p>
<p><strong>Fake newlines:</strong><br /><br><br /></p>
$ cat pm_1082082_2.html
<h1 id="H-2">Heading 2</h1>
<p class="sub-heading">
Some <strong>bold</strong> and <em>italic</em> text.</p>
<h2 id="H-2-2">Heading 2.2</h2>
<p>Para1 (2.2.1)</p><p>Para2 (2.2.2)</p>
<p><strong>Fake newlines:</strong><br /><br><br /></p>
Here's a sample run:
$ pm_1082082_html_tag_count.pl pm_1082082_*.html
p 8
br 6
strong 4
h1 2
em 2
h2 2
If that's not what you're after, you'll need to clarify what you do want and, as already mentioned, sample input and expected output will help.
[If you're unsure of what information to provide, the guidelines in "How do I post a question effectively?" should help.]
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.