Excerpts from the mail message of Tom Christiansen:
) run this on an html file. it gets into an infinite loop.
This has been a while but I finally looked at it and haven't
seen a reply so...
) #!/usr/bin/perl -n00
)
) while ( ($tag, $level, $text) = m{
) < (h(\d)) >
) (.*?)
) < /\1 >
) }gsix
) )
) {
) $fill = " " x $level;
) $text =~ s/^/$fill/gm;
) $text =~ s/^\s+//; $text =~ s/\s+$//;
) print "\n----\n\U$tag\E: $text\n";
) }
Both the versions below work. In other words, //m only interates
if in a scalar context so if you want to get at what matched your
subexpressions then you either have to get them all at once in an
array context or use $1, $2, etc.
#!/usr/bin/perl -n00
@_= m{
< (h(\d)) >
(.*?)
< /\1 >
}gsix;
while ( ($tag, $level, $text) = splice(@_, 0, 3) )
{
$fill = " " x $level;
$text =~ s/^/$fill/gm;
$text =~ s/^\s+//; $text =~ s/\s+$//;
print "\n----\n\U$tag\E: $text\n";
}
#!/usr/bin/perl -n00
while ( m{
< (h(\d)) >
(.*?)
< /\1 >
}gsix
)
{
($tag, $level, $text) = ($1, $2, $3);
$fill = " " x $level;
$text =~ s/^/$fill/gm;
$text =~ s/^\s+//; $text =~ s/\s+$//;
print "\n----\n\U$tag\E: $text\n";
}
--
Tye McQueen tye@metronet.com || tye@doober.usu.edu
Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)