#!/usr/bin/perl use Getopt::Long; my $title = ''; GetOptions("title=s" => \$title); sub xq { open PIPE, '-|', @_; my @res = ; close PIPE ? @res : undef; } open STDOUT, "|tidy -q" or warn "error opening tidy: $!\n"; print < $title
Click image for next image
END my $i=0; for (@ARGV) { my ($w, $h); for (xq qw(extract), $_) { ($w, $h) = ($1, $2) if m/^size - (\d+)x(\d+)$/; } my $opt = (defined $w && defined $h) ? "width=$w height=$h" : ""; printf qq(

). qq(%s

\n), $i, $i+1, $_, $_; ++$i; } print "
\n";