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

Re: Re: Re: Writing an opinion poll in perl.

by PodMaster (Abbot)
on Sep 20, 2003 at 10:50 UTC ( [id://292841]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Writing an opinion poll in perl.
in thread Writing an opinion poll in perl.

PerlMonks messes up the first table, so it's in code tags. I also had HTML::BarGraph laying around, but I never use it, so no example ;)
use HTML::BarChart; use CGI qw[ *table Tr td br Th ]; my $survey = 'I think pasta is good'; my %survey = ( 'Strongly agree' => '********', 'Agree' => '**', 'Disagree' => '*************', 'Strongly disagree' => '****' ); my $flippy = 0; my $Chart = HTML::BarChart->new( $survey, 100, 100 ); foreach my $key ( keys %survey ) { $Chart->bar( $key, length $survey{$key}, $flippy ? $flippy++ && "red" : $flippy-- && "black" ); } $Chart->draw; print start_table({-border=>1}),Th({-colspan=>2}, $survey ); foreach my $key ( keys %survey ) { print Tr( td({ -height => "30", -bgcolor => "red" },$key), td($survey{$key} ) ); } print end_table; __END__ <table bgcolor="#000000" width="100" height="100" border="0" cellp +adding="0" cellspacing="1"><tr> <td colspan="5"> <table border="0" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF +" width="100%"> <tr><td valign="top" align="center"><font size="2" face="Arial"> I think pasta is good </td></tr></table> </td></tr><tr><td colspan="5" align="center"><table bgcolor="#FFFFFF" +border="0" cellpadding="0" cellspacing="0" width="100%"><tr> <td valign="bottom" align="center" width="100"> <table height="30.7692307692308" width="25" bgcolor="0" cellpa +dding="1" cellspacing="1"> <tr><td></tr></td></table> </td> <td valign="bottom" align="center" width="100"> <table height="100" width="25" bgcolor="red" cellpadding="1" c +ellspacing="1"> <tr><td></tr></td></table> </td> <td valign="bottom" align="center" width="100"> <table height="15.3846153846154" width="25" bgcolor="0" cellpa +dding="1" cellspacing="1"> <tr><td></tr></td></table> </td> <td valign="bottom" align="center" width="100"> <table height="61.5384615384615" width="25" bgcolor="red" cell +padding="1" cellspacing="1"> <tr><td></tr></td></table> </td> </tr></table></td></tr><tr><td><table width="100%" border="0" cellpadd +ing="0" cellspacing="1" bgcolor="#FFFFFF"><tr> <td align="center"><font size="1" face="Arial">Strongly disagree</ +font></td></tr></table></td> <td><table width="100%" border="0" cellpadding="0" cellspacing="1" bgc +olor="#FFFFFF"><tr> <td align="center"><font size="1" face="Arial">Disagree</font></td +></tr></table></td> <td><table width="100%" border="0" cellpadding="0" cellspacing="1" bgc +olor="#FFFFFF"><tr> <td align="center"><font size="1" face="Arial">Agree</font></td></ +tr></table></td> <td><table width="100%" border="0" cellpadding="0" cellspacing="1" bgc +olor="#FFFFFF"><tr> <td align="center"><font size="1" face="Arial">Strongly agree</fon +t></td></tr></table></td> </tr></table>
I think pasta is good
Strongly disagree ****
Disagree *************
Agree **
Strongly agree ********

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2025-04-25 18:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.