Welcome to European Tribune. It's gone a bit quiet around here these days, but it's still going.
Gaw, code is annoying to post. I think this should be okay. You can see the extent to which I am not a hardcore perl freak in that the script is longer than 3 lines.
As a bonus, the script to turn a script into postable text is provided.
$cellspacing = 0;
$cellpadding = 0;

$lw = 35;              # width of the last column in the table in percent.
                       #(Comment furthest to the right will never be more
                       #narrow than this. Indentation will adjust to maximum
                       #comment nesting
$ecc = "#FFFFFF";      #color of empty cells (space to the left of nested commenst)
$ccc = "#FFFFFF";      #color of cells with comments
#$tb = "border=\"1\"";

open OUT, ">$ARGV[1]" or open OUT, ">-" or die;
open IN, "$ARGV[0]" or die "specify input filename or - for stdin\n";

@text = <IN>;
$" = "";
$text = "@text";
#$text =~ s/\n//g;
@comments = split(/<\!--\s*start\s*comment\s*-->/, $text);
$" = "\n";
foreach $comment(@comments){
    $comment =~ /<a id="(.*)"\s*class="commenttitle">/si;
    $num = $1;
    $nums[$i++] = $num;
    if($comment =~ /#([0-9]*)">parent/si){
       $parents[$num] = $1;
    $level[$num] = $level[$1]+1;
    $level[$num] = 0;
    $maxlevel = $level[$num]};
    $comment =~ /<div class="commentbody">(.*)<\/div>.*<span class/s;
    $combodies[$num] = $1;
    $comment =~ /class="commenttitle">(<b>[^<]*<\/b>)<\/a>/si;
    $titles[$num] = $1;
    $comment =~/<span class.*by<\/i>\s*<a [^>]*href="([^>]*)">([^<]*)</s;
    $authors[$num] =$2;
    $authpage[$num] = $1;
    $comment =~ />([^<]*FWT)/s;
    $ptime[$num] = $1;

$wpc = (100-$lw)/($maxlevel);
print OUT "<table $tb><tr>\n";
    print OUT "<td width=\"$wpc%\"></td>";
print OUT "<td width=\"$lw%\"></td></tr>";
foreach $num(@nums){
    $rs1 = $level[$num];
    $rs2 = $maxlevel-$rs1+1;
    $fcw = $rs1*$wpc;
    $scw = 100-$fcw;
    print OUT "<tr>\n";
        print OUT "<td colspan=\"$rs1\" style=\"background-color: $ecc\"> </td>"; # width=\"$fcw%\";
    print OUT "<td colspan=\"$rs2\"  style=\"background-color: $ccc\">"; #width=\"$scw%\"
    print OUT "<a id=\"ct$num\">";
    print OUT "$titles[$num]</a><br>$combodies[$num]<br>\n";
    print OUT "by <a href=\"$authpage[$num]\">$authors[$num]</a> on $ptime[$num]";
        print OUT "<a href=\"#ct$parents[$num]\"> parent</a>";
    print OUT "<hr width=\"100%\"></td></tr>\n\n";

print OUT "</table>\n";

For posting a perl script as a comment. Also works on html turning < and > into &lt; and &gt; (and & into &amp; which becomes &amp;amp; in the next iteration.)

open OUT, ">$ARGV[1]" or open OUT, ">-" or die;
open IN, "$ARGV[0]" or die "specify input filename or - for stdin\n";
@text = <IN>;
$" = "";
$text = "@text";
$text =~ s/&/&amp;/igs;
$text =~ s/</&lt;/igs;
$text =~ s/>/&gt;/igs;
$text =~ s/\n/<br>/igs;
$text =~ s/\t/    /igs;
$text =~ s/\s\s/&nbsp; /igs;
$text =~ s/\s\s/&nbsp; /igs;
$text =~ s/<br>/<br>\n/igs;

print OUT "<tt>$text</tt>\n";

by someone (s0me1smail(a)gmail(d)com) on Sat Jan 6th, 2007 at 06:28:43 PM EST
[ Parent ]

Others have rated this comment as follows:

kcurie 4


Occasional Series