Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^15: Processing Two XML Files in Parallel

by dreadpiratepeter (Priest)
on Jul 24, 2011 at 12:58 UTC ( #916404=note: print w/ replies, xml ) Need Help??


in reply to Re^14: Processing Two XML Files in Parallel
in thread Processing Two XML Files in Parallel

That is a horribly poor comparison. You simplify for an 8-year old because he is probably unable to comprehend the real answer. A beginning Perl programmer is presumably and adult and shouldn't need the simplification. They will benefit more from being shown the right way to do things from the start.

Plus, your solution was not a simplification, but the wrong way to solve the problem. See the hundreds of posts detailing why you shouldn't use regular expressions to parse XML.

I would much rather the beginner have to work a little harder to learn the right way, than to be stuck six months down the line when everything blows up because someone added an attribute to the XML. or even a newline

And actually, I would not even call ikegami's solution harder to understand. Sure, it requires you to actually read a PerlDoc to understand it,but how lazy (the bad kind, not Perl Lazy) do you have to be for that to be the issue? And there is no reason why the user couldn't learn by replying with follow up questions about the code and the idioms used; thereby learning more and creating robust code.

With your method, the beginner gets a fragile one-off that reinforces a bad methodology. With ikegami's he learns a valuable tool that can help him solve more complex problems safely and easily

Your comment elswehere in the thread is telling:

Why oh why, do you need all that complexity to do a simple task? WHY???? I refuse to learn how to write code which has to be that verbose, without some sort of damn good reason! ... What ever happened to keep it simple?

your good reason is robustness and reliability. Keep it simple is secondary to do it right.



-pete
"Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."


Comment on Re^15: Processing Two XML Files in Parallel
Re^16: Processing Two XML Files in Parallel
by Logicus on Jul 24, 2011 at 14:13 UTC
    robustness and reliability

    Good point!

    I'd give you the double plus if I wasn't 3 floors underneath the dungeon level!

    I did ask if there was a 1-to-1 line concurrency, so you can infer from that that I was aware that the solution would not work if there was any mismatch in the line concurrency. Also adding .*? inside the left tag would catch any randomly added attributes, but yes, I can see why regex's are not the way to go if your less than 100% sure about the quality and consistency of the input data.

    So that leaves me wondering just exactly how XML::libXML recognises the structure of a tag, what is the black magic therein? And also, how does libXML work on the file without loading it all into memory (the guy said they were extremely large.)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2014-12-21 13:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (105 votes), past polls