Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
April Fool's silliness
Below is some code that formats tables -- shades alternate rows -- used in an intranet application internally...
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!....
Anyway, on April Fools, I set  $silly to true using  rand about 1 in 10 times.... truly horrible.

nop
sub table { my $html = shift; my $i=1; $html =~ s{<\s*(t\w+)}{ if (lc($1) eq "tr") {$i++; "<tr";} elsif (lc($1) eq "td") { (($i%2) == 1) ? '<td bgcolor="#F4FAFF" align="center"' : '<td bgcolor="#E1f1FF" align="center"';} elsif (lc($1) eq "th") { (($i%2) == 1) ? '<th bgcolor="#F4FAFF" align="center"' : '<th bgcolor="#E1f1FF" align="center"';} else {"<$1"} }iegm; if (!$silly) {return $html;} my $dir; $html =~ s{<td.*?>(.*?)<\/td>}{ $dir = (qw(left right up down))[rand()*4]; if (rand()<.2) { "<td><marquee direction=\"$dir\" behavior=\"alternate\" height +=\"40\" vspace=\"2\">$1</marquee></td>"; } else { "<td>$1</td>"; } }ieg; return $html; }

In reply to Re: My April Fools Prank is by nop
in thread My April Fools Prank is by vroom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (3)
    As of 2014-10-26 08:03 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (152 votes), past polls