Welcome to European Tribune. It's gone a bit quiet around here these days, but it's still going.
Display:
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";
$i=0;
foreach $comment(@comments){
    $comment =~ /<a id="(.*)"\s*class="commenttitle">/si;
    $num = $1;
    $nums[$i++] = $num;
    if($comment =~ /#([0-9]*)">parent/si){
       $parents[$num] = $1;
   }
    if($parents[$num]){
    $level[$num] = $level[$1]+1;
    }
    else{
    $level[$num] = 0;
    }
    if($maxlevel<$level[$num]){
    $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";
for($k=0;$k<$maxlevel;$k++){
    print OUT "<td width=\"$wpc%\"></td>";
}
print OUT "<td width=\"$lw%\"></td></tr>";
foreach $num(@nums){
    if($combodies[$num]){
    $rs1 = $level[$num];
    $rs2 = $maxlevel-$rs1+1;
   
    $fcw = $rs1*$wpc;
    $scw = 100-$fcw;
    print OUT "<tr>\n";
    if($rs1!=0){
        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]";
    if($parents[$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

Display:

Top Diaries

Occasional Series