Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Bull$#!^ Bingo (was :By far, the coolest use for perl)

by shirkdog_perl (Beadle)
on Dec 05, 2002 at 15:59 UTC ( #217791=CUFP: print w/replies, xml ) Need Help??

Using a nice shuffler from the Perl Cookbook, and information from a very funny email, I created this CGI script to generate a Bullshit Bingo Card. The game works as such, every player has a card when attending a meeting. When bullshit is said, you score it on your card. When someone aquires 5 in a row, they stand up and yell BULLSHIT. The html print statements are sloppy, however, I whipped this up in 5 mins, and was on webserver serving out cards in 2.
#!/usr/bin/perl -wT # # BullShit Bingo Script Version 1.1 Last Modified 6/17/02 11:20 # --Michael Shirk # Generates a random Bullshit bingo card when called from the # webserver, and prints it in HTML. # ################################################################# use strict; use CGI; my $q = new CGI; my @array = ("Synergy", "Strategic fit", "Core competencies", "Out of +the box", "Bottom line", "Revisit", "Take that off line", "24/7", "O +ut of the loop", "Benchmark", "Value-added", "Proactive", "Win-win", "Think out + side the box", "Fast track", "Result driven", "Empower (ment)", "Knowledge ba +se", "At the end of the day", "Touch base", "Mindset", "Client focus (ed)", "Ballpark", "Gam +e plan", "Leverage", "Top down", "User friendly", "On time", "Within bu +dget", "Forecast", "Optimistic"); sub shuffle { my $array = shift; my $i; for ($i = @$array; --$i; ) { my $j = int rand ($i+1); next if $i == $j; @$array[$i,$j] = @$array[$j,$i]; } for (my $k = 0; $k < $#array; $k++) { print $array[$k]; } } shuffle( \@array ); print "Content-type: text/html"; print "\n"; print "\n"; print "<html>"; print "<body>"; print "<h1 align=\"center\">Bullshit Bingo</h1>"; print "<table width=\"100%\" height=\"400\" border=\"3\" align=\"cente +r\">"; print "<tr>"; print "<td><br><br><br><p align=\"center\">$array[0]<br><br><br></td>" +; print "<td><br><br><br><p align=\"center\">$array[1]<br><br><br></td>" +; print "<td><br><br><br><p align=\"center\">$array[2]<br><br><br></td>" +; print "<td><br><br><br><p align=\"center\">$array[3]<br><br><br></td>" +; print "<td><br><br><br><p align=\"center\">$array[4]<br><br><br></td>" +; print "</tr>"; print "<tr>"; print "<td><br><br><br><p align=\"center\">$array[5]<br><br><br></td>" +; print "<td><br><br><br><p align=\"center\">$array[6]<br><br><br></td>" +; print "<td><br><br><br><p align=\"center\">$array[7]<br><br><br></td>" +; print "<td><br><br><br><p align=\"center\">$array[8]<br><br><br></td>" +; print "<td><br><br><br><p align=\"center\">$array[9]<br><br><br></td>" +; print "</tr>"; print "<tr>"; print "<td><br><br><br><p align=\"center\">$array[10]<br><br><br></td> +"; print "<td><br><br><br><p align=\"center\">$array[11]<br><br><br></td> +"; print "<td><br><br><br><p align=\"center\">$array[12]<br><br><br></td> +"; print "<td><br><br><br><p align=\"center\">$array[13]<br><br><br></td> +"; print "<td><br><br><br><p align=\"center\">$array[14]<br><br><br></td> +"; print "</tr>"; print "<tr>"; print "<td><br><br><br><p align=\"center\">$array[15]<br><br><br></td> +"; print "<td><br><br><br><p align=\"center\">$array[16]<br><br><br></td> +"; print "<td><br><br><br><p align=\"center\">$array[17]<br><br><br></td> +"; print "<td><br><br><br><p align=\"center\">$array[18]<br><br><br></td> +"; print "<td><br><br><br><p align=\"center\">$array[19]<br><br><br></td> +"; print "</tr>"; print "<tr>"; print "<td><br><br><br><p align=\"center\">$array[20]<br><br><br></td> +"; print "<td><br><br><br><p align=\"center\">$array[21]<br><br><br></td> +"; print "<td><br><br><br><p align=\"center\">$array[22]<br><br><br></td> +"; print "<td><br><br><br><p align=\"center\">$array[23]<br><br><br></td> +"; print "<td><br><br><br><p align=\"center\">$array[24]<br><br><br></td> +"; print "</tr>"; print "</table>"; print $q->end_html;

edited: Thu Dec 5 19:02:13 2002 by jeffa - title change

Replies are listed 'Best First'.
•Re: Bull$#!^ Bingo
by merlyn (Sage) on Dec 05, 2002 at 16:25 UTC
    My take:
    #!/usr/local/bin/perl use CGI qw(:all); my @array = ("Synergy", "Strategic fit", "Core competencies", "Out of the box", "Bottom line", "Revisit", "Take that off line", "24/7", "Out of the + loop", "Benchmark", "Value-added", "Proactive", "Win-win", "Think out side + the box", "Fast track", "Result driven", "Empower (ment)", "Knowledge base", +"At the end of the day", "Touch base", "Mindset", "Client focus (ed)", "Ballpark", "Game pla +n", "Leverage", "Top down", "User friendly", "On time", "Within budget" +, "Forecast", "Optimistic"); print header, start_html; print table({ border => 2, cellspacing => 0, cellpadding => 10 }, map { Tr( map { td( { align => 'center' }, splice @array, rand scalar @array, 1 ) } 1..5 ) } 1..5 ); print end_html;

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

(jeffa) Re: Bull$#!^ Bingo
by jeffa (Bishop) on Dec 05, 2002 at 18:32 UTC
    I think that merlyn's CGI.pm solution looks more consise, but here is another version anyway ... it uses HTML::Template:
    use CGI qw(header); use HTML::Template; my @array = ( "Synergy", "Strategic fit", "Core competencies", "Out of the box", "Bottom line", "Revisit", "Take that off line", "24/7", "Out of the loop", "Benchmark", "Value-added", "Proactive", "Win-win", "Think out side the box", "Fast track", "Result driven", "Empower (ment)", "Knowledge base", "At the end of the day", "Touch base", "Mindset", "Client focus (ed)", "Ballpark", "Game plan", "Leverage", "Top down", "User friendly", "On time", "Within budget", "Forecast", "Optimistic", ); my $html = do {local $/;<DATA>}; my $tmpl = HTML::Template->new(scalarref => \$html); # double map borrowed from merlyn and slightly altered $tmpl->param( row => [ map {{ col => [ map { { data => splice(@array, rand scalar @array, 1) } } 1..5 ] }} 1..5 ] ); print header, $tmpl->output; __DATA__ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Bullshit Bingo</title> </head> <body> <table cellpadding="10" border="2" cellspacing="0"> <tmpl_loop row> <tr> <tmpl_loop col> <td align="center"><tmpl_var data></td> </tmpl_loop> </tr> </tmpl_loop> </table> </body> </html>

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: Bull$#!^ Bingo
by shirkdog_perl (Beadle) on Dec 05, 2002 at 16:43 UTC
    That looks great Randall, I did appolgize for the sloppy NON-CGI.pm usage. I had only a few minutes before the meeting. :-)
Re: Bull$#!^ Bingo (was :By far, the coolest use for perl)
by simon.proctor (Vicar) on Dec 06, 2002 at 20:55 UTC
    If you like this then I suggest you take a look at Lingo Bingo. You'll need Acrobat for the PDF cards.

    If nothing else it will give you a few more buzzwords for your game :)
Re: Bull$#!^ Bingo (was :By far, the coolest use for perl)
by shirkdog_perl (Beadle) on Dec 08, 2002 at 03:51 UTC
    Interesting Simon, makes me wonder if this site had the idea first, then someone just sent a rip-off email around.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://217791]
Approved by ybiC
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2023-01-29 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?