Maybe the idea is a bit sick, but it was the easy way out to avoid having to parse the nesting. The approach is not common: first, I convert the POD document to a piece of code that returns a single string, in this case HTML formatted.

Comments are welcome!

#!/usr/bin/perl -w # unfinished code, possibly insecure. use strict; sub AUTOLOAD { shift }; sub pod_blank { "<p>" } sub pod_code { "<pre>$_[0]</pre>" } sub pod_C { "<tt>$_[0]</tt>" } sub pod_I { "<i>$_[0]</i>" } sub pod_B { "<b>$_[0]</b>" } sub pod_S { "<nobr>$_[0]</nobr>" } sub pod_F { "<tt>$_[0]</tt>" } sub pod_Z { "<span></span>" } sub pod_L { # XXX - needs a lot of work (split /\|/, shift)[0] } sub pod_E { $_[0] =~ /^\d+$/ ? "&#$_[0];" : { qw(lt < gt > sol / verbar |) }->{ $_[0] } || "&$_[0];" } sub pod_head1 { "<h1>$_[0]</h1>" } sub pod_head2 { "<h2>$_[0]</h2>" } sub pod_over { "<ul>" } sub pod_back { "</ul>" } sub pod_item { "<li>$_[0]</li>" } sub pod_PRE { local $_ = shift; s/&/&amp;/g; $_; } sub pod_POST { local $_ = shift; s/</&amp;lt;/g; s/>/&gt;/g; "<html><body>$_</body></html>"; } ### my $pod = do { local $/ = undef; open my $fh, 'pod' or die $!; readline $fh; }; $pod = pod_PRE($pod); $pod =~ s/([\[\]\$\@\\])/\\$1/g; $pod =~ s/^[^\n\S]*$/\${\\ pod_blank() }/gm; $pod =~ s/^=(\w+)(?: ?(.*))?/\${\\ pod_$1(qq[$2]) }/gm; $pod =~ s/^((?:[^\n\S].*\n?)+)/\${\\ pod_code(qq[$1]) }/gm; for (2..6) { my $op = '<' x $_; my $cl = '>' x $_; while ($pod =~ /([IBSCLFXZE])$op (.*?) $cl/) { $pod =~ s//\${\\ pod_$1(qq[$2]) }/g; } } while ($pod =~ /([IBSCLFXZE])<(.*?)>/) { $pod =~ s//\${\\ pod_$1(qq[$2]) }/g; } $pod = 'qq[' . pod_POST($pod) . ']'; print eval $pod;

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.