<?xml version="1.0" encoding="windows-1252"?>
<node id="68570" title="Re: My April Fools Prank is" created="2001-03-30 22:55:51" updated="2005-08-13 01:12:43">
<type id="11">
note</type>
<author id="29594">
nop</author>
<data>
<field name="doctext">
&lt;strong&gt; April Fool's silliness &lt;/strong&gt;
&lt;br&gt;
Below is some code that formats tables --  shades
alternate rows -- used in an intranet application internally... &lt;br&gt; yeah, yeah, yeah, I know the code is ugly, but it works, and I didn't know much perl when I wrote it... so please be gentle on this old code!....  &lt;br&gt;
Anyway, on April Fools, I set &lt;code&gt; $silly &lt;/code&gt; to true using &lt;code&gt; rand &lt;/code&gt; about 1 in 10 times.... truly horrible.
&lt;br&gt;&lt;br&gt;
[nop]
&lt;code&gt;
sub table {
    my $html = shift;
    my $i=1;
    $html =~ s{&lt;\s*(t\w+)}{
	if (lc($1) eq "tr") {$i++; "&lt;tr";} 
	elsif (lc($1) eq "td") {
	    (($i%2) == 1) ? '&lt;td bgcolor="#F4FAFF" align="center"' : 
	            '&lt;td bgcolor="#E1f1FF" align="center"';}
	elsif (lc($1) eq "th") {
	    (($i%2) == 1) ? '&lt;th bgcolor="#F4FAFF" align="center"' : 
	            '&lt;th bgcolor="#E1f1FF" align="center"';}
	else {"&lt;$1"}
    }iegm;
    if (!$silly) {return $html;}
    my $dir;
    $html =~ s{&lt;td.*?&gt;(.*?)&lt;\/td&gt;}{
	$dir = (qw(left right up down))[rand()*4];
	if (rand()&lt;.2) {
	    "&lt;td&gt;&lt;marquee direction=\"$dir\" behavior=\"alternate\" height=\"40\"  vspace=\"2\"&gt;$1&lt;/marquee&gt;&lt;/td&gt;";
	} else {
	    "&lt;td&gt;$1&lt;/td&gt;";
	}
    }ieg;
    return $html;
}
&lt;/code&gt;</field>
<field name="root_node">
68566</field>
<field name="parent_node">
68566</field>
</data>
</node>
