CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Need help with a poll script

 



broomsy
stranger

Jul 17, 2001, 4:03 PM

Post #1 of 6 (843 views)
Need help with a poll script Can't Post

I am working with a poll script that I obtained from a site and I am modifying it myself. So far I am adding the percent to the script but it has too many decimal places. The url to the script is http://www.realgamers.co.uk/cgi-bin/rgpoll/poll.cgi Can anyone help me?



abstracts
Novice

Jul 17, 2001, 4:41 PM

Post #2 of 6 (839 views)
Re: Need help with a poll script [In reply to] Can't Post

Hello,
Just use printf or sprintf like

Code
printf("%.2f\n", 22.5667);

Hope this helps,,,

Aziz,,,



broomsy
stranger

Jul 17, 2001, 4:44 PM

Post #3 of 6 (838 views)
Re: Need help with a poll script [In reply to] Can't Post

Sorry I am not very good with perl. This is the code I have got at the minute:
$currperc=( $votes[$a] * 100 ) / $total;
$out_choices .= "<tr><td>@choices[$a] <font color=#F08442>(@votes[$a])</font>
<img src=\"$file_image\" height=10 width=@imgwidths[$a]> $currperc \%";
What do I need to change



abstracts
Novice

Jul 17, 2001, 7:05 PM

Post #4 of 6 (834 views)
Re: Need help with a poll script [In reply to] Can't Post


Code
$currperc = sprintf "%.2f", $votes[$a] * 100 / $total; 
$out_choices .= "<tr><td>$choices[$a] <font color=#F08442>($votes[$a])</font>
<img src=\"$file_image\" height=10 width=$imgwidths[$a]> $currperc \%";

Hope this helps,,,

Aziz,,,



broomsy
stranger

Jul 18, 2001, 2:29 AM

Post #5 of 6 (829 views)
Re: Need help with a poll script [In reply to] Can't Post

Thanks very much for your help. If you look at my poll again you will see it works correctly. Are you experienced with perl? Would you consider helping me further?



abstracts
Novice

Jul 18, 2001, 3:14 AM

Post #6 of 6 (828 views)
Re: Need help with a poll script [In reply to] Can't Post

Hello,
Questions should be directed to this board so that we all get to share the knowledge. And yes, I do help when I can.

Aziz,,,


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives