Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Testing your code is a great concept. Of course, we all have to agree on the specs so we can all agree on what tests are needed. Your code works just fine for a certain subset of possibilities, dbwiz's code works just fine for a different subset of possibilities, both work just fine for the subset of posssibilities as presented by the OP. In the absence of a better spec, we all make assumptions that show the world that we, individually, live in more than they show the world that the OP lives in. (Which is why, if you look back at questions I pose, they're usually quite long-winded - to reduce the "absence of a better spec".)

As for the initial letters, not that we're straying from the initial thread here ;-), I'd recommend matching with /^([[:alpha:]]*)/ instead. Again, we have to agree on a spec of what "initial letters" means (does it mean English letters, or can it include accented characters, or letters in other non-Roman lettering systems?). If it includes other languages, I like letting perl worry about that stuff for me ;-). Note that it is perfectly reasonable to only accept straight-ascii for some things. We just can't tell from what has been stated so far. (And I've just revealed a bit more about the world I live in.)

In reply to Re^4: what is the best way to seperate the digits and strings from variable ? by Tanktalus
in thread what is the best way to seperate the digits and strings from variable ? by swaroop

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (3)
    As of 2017-11-22 04:26 GMT
    Find Nodes?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:

      Results (315 votes). Check out past polls.