in reply to Making XP Change

Heh.. this is great. One small bug fix needed though:
$ perl xp_o.pl 2731 XP = 2731 2731.00 initiates 136.55 novices, 11 to promotion 54.62 acolytes, 31 to promotion 27.31 scribes, 31 to promotion 13.65 monks, 131 to promotion 5.46 friars, 231 to promotion 2.73 abbots, 731 to promotion 1.71 bishops, 1131 to promotion 1.19 pontiffs, 431 to promotion 0.91 saints, 2731 to promotion a pontiff, 2 monks, a novice, and 1a initiates

Note the "1a initiates". It should be 11. Replace the final bit with:

s<(?:^|\D)(1 [a-z]+(?:, 1 [a-z]+)*)>{ my @ranks = $1 =~ /[a-z]+/g; " a " . join( ', ', @ranks ) }ge; s/^ //; if ( /,.+,/ ) { s/(.+),([^,]+)/$1, and$2/; } print

Which gives:

$ perl xp.pl 2731 XP = 2731 2731.00 initiates 136.55 novices, 11 to promotion 54.62 acolytes, 31 to promotion 27.31 scribes, 31 to promotion 13.65 monks, 131 to promotion 5.46 friars, 231 to promotion 2.73 abbots, 731 to promotion 1.71 bishops, 1131 to promotion 1.19 pontiffs, 431 to promotion 0.91 saints, 2731 to promotion a pontiff, 2 monks, a novice, and 11 initiates

Replies are listed 'Best First'.
Re^2: Making XP Change
by diotalevi (Canon) on Jun 09, 2005 at 21:37 UTC
    Oh, sorry. Isn't this just the most excrebale code you've ever seen put out by someone supposedly competent? *wink*