JimDuyer has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl print "Content-type: text/html\n\n"; use strict; use POSIX qw( ceil floor ); my $num = 9998; my $string1=''; my $string2=''; my $string3=''; my $string4=''; my $first8 = floor($num/8000); my $a = ($first8*8000); if ($first8 > 0) { $string1 .="1st line has $first8 times 8000 = $a"; } else { $string1 .="1st line has nothing "; } print "$string1 <br>\n"; my $second8= $num - $a; $second8 = floor($second8/400); my $b = ($second8*400); if ($second8 > 0) { my $third8 = $num - $second8 - ($second8*400); $string2 .="2nd line has $second8 times 400 = $b"; } else { $string2 .= "2nd line has nothing"; } print "$string2 <br>\n"; my $third8= $num-$a-$b; $third8 = floor($third8/20); my $c = ($third8*20); if ($third8 > 0) { $string3 .="3rd line has $third8 times 20 = $c"; } else { $string3 .="3rd line has nothing"; } print "$string3 <br>\n"; my $cumulative = $num - $a - $b - $c; if ($cumulative > 1) { $string4.="4th line has 1 times all = $cumulative"; } else { $string4.= "NOTHING LEFT OVER "; } print "$string4<br>\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Base20 Blues
by ikegami (Patriarch) on Jan 10, 2011 at 00:46 UTC | |
by chrestomanci (Priest) on Jan 10, 2011 at 09:11 UTC | |
by Anonymous Monk on Jan 10, 2011 at 13:40 UTC | |
by ikegami (Patriarch) on Jan 10, 2011 at 15:47 UTC | |
|
Re: Base20 Blues
by Anonyrnous Monk (Hermit) on Jan 10, 2011 at 02:08 UTC | |
|
Re: Base20 Blues
by zentara (Cardinal) on Jan 10, 2011 at 12:00 UTC | |
|
Re: Base20 Blues
by PeterPeiGuo (Hermit) on Jan 10, 2011 at 00:50 UTC |