Stellarcore.net

Stellarcore.net

The Perl version of the script

#!/usr/bin/perl

#Globals
my $max_lvl = 40;

#Main
   system "clear";
   #Windows or DOS use
   #system "cls";
   #Headers
   print "Char \t \tClass Skill\tCC Skill\t \tStat\t\n";
   print "Level\tXP\tMax Ranks\tMax Ranks\tFeats\tIncreases\t\n";

   #Main loop
   my $xp = 0;
   my $feats= 0;
   my $stats = 0;

   for my $level ( 1 .. $max_lvl ) {
      $xp = ($xp + ($level - 1) * 1000);
      my $maxranks = $level + 3;
      my $maxcc = $maxranks / 2.0;

      my $feats_check = $level % 3;
      my $feats_out = '--';
      if ( ($feats_check == 0) || ( $level == 1) ) {
         $feats++;
         $feats_out = &level_th($feats);
      }

      my $stat_check = $level % 4;
      my $stats_out = '--';
      if ($stat_check == 0) {
         $stats++;
         $stats_out = &level_th($stats);
      }

      my $level_out = &level_th($level);
      #output
      print " $level_out\t$xp\t$maxranks\t\t$maxcc\t\t$feats_out\t$stats_out\t\n";
   }

exit;

#level_th foramts numbers into 1st,2nd,3rd.... 
sub level_th {
   my $s_input = shift;
   my $level_th;

   $s_input =~ m/(\d{1})$/;
   my $s_check = $1;

   if ( ($s_input eq "11") || ($s_input eq "12") || ($s_input eq "13") ) {
      $level_th = "$s_input" . "th"; 
   } elsif ( $s_check eq "1" ) {
      $level_th = "$s_input" . "st"; 
   } elsif ( $s_check eq "2" ) {
      $level_th = "$s_input" . "nd"; 
   } elsif ( $s_check eq "3" ) {
      $level_th = "$s_input" . "rd"; 
   } else {
      $level_th = "$s_input" . "th"; 
   }

   return $level_th;
}
# vi: shiftwidth=3 tabstop=3 et