#!/usr/bin/perl use warnings; use strict; use Lingua::EN::Inflect 'A'; my ($day, $level, $xp); $level = {xp => 0, votes => 0, title => "initiate", next => {xp => 20, votes => 5, title => "novice", next => {xp => 50, votes => 8, title => "acolyte", next => {xp => 100, votes => 12, title => "scribe", next => {xp => 200, votes => 16, title => "monk", next => {xp => 500, votes => 20, title => "friar", next => {xp => 1000, votes => 25, title => "abbot", next => {xp => 1600, votes => 30, title => "bishop", next => {xp => 2300, votes => 35, title => "pontiff", next => {xp => 3000, votes => 40, title => "saint"}}}}}}}}}}; $| = 1; print "Enter your current xp: "; chomp($xp = ); die "Doesn't look quite like an xp to me\n" if $xp ne do { no warnings 'numeric'; 0+$xp }; $day = 0; while ($level->{next}) { # bonus for casting all votes (through level 5) $xp += int($level->{votes}/6) if $day > 0 && $level->{votes} < 16; # (update:corrected from <= 16) ($level = $level->{next}) and print("Day $day: you are ", A($level->{title}), "\n") while $level->{next} && $xp >= $level->{next}{xp}; ++$day; # 25% chance for each vote cast (rand(4) < 1) and ++$xp for 1..$level->{votes}; # 25% chance for 2 xp for logging in (rand(4) < 1) and $xp += 2; }