Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re: Making XP Change by Paladin
in thread Making XP Change by diotalevi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-18 04:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found