Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Making XP Change

by Paladin (Vicar)
on Jun 09, 2005 at 21:04 UTC ( [id://465325]=note: print w/replies, xml ) Need Help??


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*

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://465325]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-03-29 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found