Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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

Replies are listed 'Best First'.
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?
[ambrus]: If you don't do that, some people will be able to use only two thirds of the available screen area, or have to prepare three versions of their slides, each of which is a waste that you could avoid with one simple phrase in the call for papers.
[Corion]: As for somebody hosting national conferences, we don't always know the kind of connectors and aspect ratios available ;)
[ambrus]: Corion: well sure, but that's the similar to any printed document, and the margin is diminishing with today's technology. Video games no longer have to assume that the CRTs won't show the edges of the screen.
[Corion]: If you cram your slides with that much information, they might work in an "offline" situation but not very well for a live presentation IMO
[ambrus]: Corion: in that case I also ask the people who rent the conference rooms to tell conference organizers about the available tech.
[Corion]: ambrus: No, you're misunderstanding. If you place content too far on the left/right/top/ bottom, people might not see it because the view is obstructed ;)(
[Corion]: In Amsterdam, the screen went down to the bottom of the stage (60cm above ground) and the seating was on the ground, meaning that the rows in the back couldn't see the bottom of slides.
[Corion]: There also were some columns that meant that maybe you couldn't see the left/right edge of a slide.
[ambrus]: Corion: Sure. I've had a course in a 50 seat lecture hall that has two fucking columns in the middle.
[Corion]: Talking about it, the top should be fairly visible in the situations I've experienced at least. The top is uncomfortable for people in the first three rows, but that's life ;)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2017-09-26 10:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (293 votes). Check out past polls.

    Notices?