No offense, but whenever I see someone say "I don't want to use a module for this", it suggests to me that they know a module is available but they just don't want to bother to learn it. I could go on about the issues with that, but most of us have heard them sooooo many times. Either you're willing to do things well or you want to scrape by. I don't mind someone "scraping by" (so long as they're not a co-worker), but to come out and tell someone that you are not willing to consider valid responses which are typically more likely to be correct...

Virtually any trivial regex solution that you will be is going to choke on embedded newlines (if any) or if the "desc" (doubtless human entered) ever contains angle brackets:

<desc>Use only with "<code>" tags</desc>

Further, a good XML module based solution will more likely handle changes to the XML in the future. In other words, if someone reorders those tags or adds more tags in the future, a regex solution will break (regexes match text) and an XML solution will be more likely to work (because it will parse the text).

This may be a rare case, admittedly, but if you learn how to do it correctly now, that's another tool under your belt (and another potential line on your resume).

By spending an extra five minutes now, you know your code is more likely to work in the future and you're lazy enough that you don't want to go back and fix it. Remember, laziness is a Perl virtue.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to Re: No xml module please by Ovid
in thread No xml module please by DS

Title:
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, details, 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, summary, 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.