#!/usr/bin/perl -w
require 5.002;
# or 5.001 if you remove the comments!
use strict;
undef $/;
@ARGV = ('-') unless @ARGV;
my($title, $filename);
print "
Bodmas pages
\n";
while ($filename = pop) {
unless (open(HTML, $filename)) {
warn "can't open $filename: $!";
next;
}
my $html = ;
my $count = 0;
while ( $html =~ m{
< \s* TITLE .*? > # begin tag
\s* (.*?) \s* # contents
< \s* / \s* TITLE .*? > # end tag
}gsix ) {
if ($count++) {
warn "$filename has $count titles!\n";
}
($title = $1 || "") =~ s/\s+/ /g;
print "- ".$title."
\n";
}
}
print "
\n";
format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$filename, $title
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
~~ $title
.