Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I can see right now a BIG problem with this line:

if ($XML_process_line =~ /^(\d{1,10})([\%|\<].{1,1000}\>)/){

I don't think it does what you want. First of all, this: [\%|\<]. You use [] and |, I think you want one or the other. If you want to alternate between % and <, use [\%<].

Second, and more important, this: .{1,1000}>. Perl's regexes are greedy, that means that if you do this: "<one></one>" =~ /<(.{1,1000})>/;print $1;, you're going to get one></one printed, because it matches as many characters as possible before stopping.

Instead, you'd want to use [\%|\<][^>]{1,1000}>, which uses a negative character class.

That being said, this is hard to do and even harder to do right, so you should use a module. I would suggest XML::Twig, but there plenty of others as well.

elusion :

Update: I also noticed that you use two variables for your line. You assign to $XML_line, but use your regex on $XML_process_line. Remember to use -w and strict.

In reply to Re: Removing duplicate subtrees from XML by elusion
in thread Removing duplicate subtrees from XML by matth

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 the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (4)
    As of 2019-08-25 02:18 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found