Hello there;
I am rather new getting back to Perl, and I needed to do a script that would convert normal numbers to Mayan Base 20 counting symbols. I have the symbols part done, but I was hoping someone could help me put my script code into shape. I'm sure you can thing of some ways to make it faster or smaller or both. I only need to do from 1 to 9999, and I am substituting anything but numbers to //. Any help would be appreciated...
#!/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";