XML::Simple for Perl Developers 186
An anonymous reader writes "XML has become pervasive in the computing world and is buried more and more deeply into modern applications and operating systems. It's imperative for the Perl programmer to develop a good understanding of how to use it. In a surprisingly large number of cases, you only need one tool to integrate XML into a Perl application, XML::Simple. This article tells you where to get it, how to use it, and where to go next."
Re:Bah, who the hell still uses perl? (Score:5, Insightful)
Re:Who The Hell Still Uses Perl? (Score:5, Insightful)
I usually don't reply to trolls, but
The answer is hundreds of thousands of people around the world who use the correct tool for a given job, rather then trying to hammer in screws with the "latest and greatest".
PS, if you're not clueless and actually are a professional software developer, you can write code in perl that is every bit as readable as . It even supports comments!
- Roach
(Who writes code in perl, as well as a number of other languages depending on the task at hand.)
Re:Bah, who the hell still uses perl? (Score:4, Insightful)
fine, I'll feed the troll.
Parsing perl with wet-ware isn't always easy. Obfuscating your code in the name of optimization should be countered with good commenting. Every useful script will have to be maintained, and the grandparent post is totally correct. I work minor miracles with Perl; or, miracles to me, anyway--I couldn't have created my dissertation data without Fortran--specifically g95 [g95.org]--and Perl.
I know there are lots of useful languages out there. Every language has its fanboys. Heck, I liked the PDP-11 macro language a lot. If people produce useful code with Perl, don't complain about it; be glad for them.
good lord... (Score:0, Insightful)
XML has become pervasive in the computing world and is buried more and more deeply into modern applications and operating systems.
Man, that's the scariest thing I've read all day. IT'S BURROWING INTO THE SYSTEM!! AHHHH!!!! ANGLE BRACKETS EVERYWHERE!
Seriously, the first thing that came to mind was the type of stuff you read on thedailywtf.com [thedailywtf.com].. something like: "And then Joe realized that the reason the string_to_upper() was so slow was because it was calling a SOAP service on a machine at the lead developer's previous employer, passing 23K of XML in both directions...." .. And then INVARIABLY, there's a reply that says "Hey, that isn't such a bad idea...."
So, no thanks, I don't want XML burying itself in my code any more than I want my music player to squirt songs.
What? (Score:4, Insightful)
This is the most pointless article I've seen linked from slashdot in a long time (and yes, I've seen a lot of crap here). What is the point of posting a run of the mill tutorial on something that's been covered many times before? [google.com]
Having spent a lot of time playing with this crap lately, can I just butt into this pointless thread and say screw XML, use YAML [yaml.org] or JSON [json.org] instead. XML is a steaming, clumsy overrated turd. I benchmarked XML::Simple [cpan.org] against YAML::Syck [cpan.org] - the latter encoded 2.5 times faster and parsed nine times faster than XML::Simple. The syck library is indeed aptly named.
"Leverage the power of XML" by deprecating it wherever you can for a more sensible cross platform format.
</rant>
Re:Who The Hell Still Uses Perl? (Score:5, Insightful)
Re:Bah, who the hell still uses perl? (Score:5, Insightful)
Hello, AC (Score:3, Insightful)
Re:Who The Hell Still Uses Perl? (Score:5, Insightful)
Since there is alot of PERL code already doing work in this environment, and PERL is on everything already... it makes sense to stick with what's there.
Re:Hello, AC (Score:5, Insightful)
You mean like the first time he messed around with regexes? Now any regex implementation that doesn't have perl's features is considered a toy. And Perl is merely catching up to Snobol and Icon.
Perl will do fine despite ignorant fools who sneer at it. Perl6 is still headed to perpetually unreleased oblivion, but some features will hopefully break off and find their way back into perl5 and elsewhere. Regexes among them.
Re:Hello, AC (Score:3, Insightful)
Re:Hello, AC (Score:5, Insightful)
Example: -> is changing to . The reason given is Which also forces . to change to ~ (also
Which also forces =~ to change to ~~
That's three major operators in the language changed with the justification that the rest of the world does one of them differently. Except, by definition, people who already knew perl.
Re:Bah, who the hell still uses perl? (Score:5, Insightful)
Perl is derided by people who quite frankly don't have a clue.
We get lots of flammage from the Java and Python programmers that seem to be unable to grasp that when they try to justify their language choices by putting down other languages, they demonstrate how clearly idiotic their choices are. They cannot come up with something better than "line noise"? My god, have they not heard of the obfuscated code contest?
One can write unreadable code in any language. Perl is not unique in this regard. Moreover, Perl itself does not admit more unreadable code than other languages. The regex engine in Perl is a language unto itself. You don't need to use it, ever. But once you do, you realize how incredibly powerful it is. And you learn how to parse it, and even more scary, emit it, in your head. What takes hundreds of lines in Java (well what doesnt) becomes single digit number of lines in Perl.
In my career, I have used APL, Assembly (x86, 8080/Z80, 6502, 6800, F8,
Perl is wonderful in that it allows for rapid application development, has a really huge library to draw from (www.cpan.org), orders of magnitude larger than competitive languages, an active developer base, an active contributer base, is portable (you can run Perl anywhere, windows, linux, mac, Cray, AIX,
Ruby is neat, though I am amused by those in the Java community running over to it, thinking it is better than Perl. It is slightly different, but the syntax is actually quite close to perl. Learning it isn't hard once you know Perl, you can go back and forth quite easily. The problem in Ruby's case is speed. This hopefully will improve over time.
Python is hard for me to use. I am reminded of BASIC on IBM PCs. Some people like it, I don't. Use it if you must.
Java has always felt to me to be a solution in search of a problem. I haven't seen things that are being done in Java that couldn't be done more quickly and efficiently in other languages. Java has developed a cult-like following. Many people drank the koolaid, committed company resources to it, and poo-pooed other, better solutions. Only to discover that each "advance" meant to deliver more performance dug people in deeper to the hole, made the systems harder and more expensive to develop. And until recently, the vast majority of people were in significant denial over the fact that java was and is just a marketing gimmick for Sun. They drank the koolaid.
Fortran
APL. You want write only? Parse this: +/x
In APL, we wrote complex calculation systems in very few lines. It was a tremendously powerful language.
In Fortran we wrote complex calculation systems in quite a few lines. Not very powerful for IO, really sucked for this.
In Perl we drive complex calculation codes written in almost any language. Insanely powerful. Expressive and concise syntax, reads well when well written. Good IO, good networking, good system hooks. Can use MVC and web tools, Jifty even comes with a pony.
Re:Who The Hell Still Uses Perl? (Score:3, Insightful)
Firstly, code written by different programmers is consistently indented. C and Java programmers could argue for a millennia about where to put the curly brace, but in the end the argument is just trivial. If everyone did it the same way code would be much more readable. Sure, the language gives you freedom to work the way you want but it does so at the expense of readability.
Another reason is that indentation easily shows that one block is the child of another. Again, this makes Python code much more readable than it otherwise would be without it.
I don't think the decision was a matter of arrogance at all. It's logical, and it makes sense. Programming is often said to be part art, part science, but trading a little bit of expression in the way you indent your code for readability (and hence maintainability) makes sense to me. It does take a bit of getting used to, sure, but it is worth the effort when you come back to the code at a later date, or try to understand someone elses.
Re:Who The Hell Still Uses Perl? (Score:3, Insightful)
Well, I can tell you that's not true. If you're willing to believe me, I'll claim that I've become very proficient at perl in the past 9 years and my code has become much easier to read. I think those who have worked with me would agree. Some have even said so specifically. You just have to have a little self dicipline and a sense of clarity and aesthetics.
Now, if you don't have such sense, or if you just like another language, that's totally cool. Whatever works for the job. But perl is a medium (like oil or watercolor) and you can make beautiful programs with it. It just doesn't do anything to assist you in that endeavor
Cheers.
Re:Who The Hell Still Uses Perl? (Score:1, Insightful)
Perl is for poets. Python is for autistic geeks who wish the world were expressed in maths.
Re:Python: syntactiacally significant whitespace.. (Score:3, Insightful)
Re:Who The Hell Still Uses Perl? (Score:3, Insightful)
Indeed. (Score:3, Insightful)
If the requirements are ill defined, or the system small enough to likely be confined to a single box, or the object model relatively simple (few types, lots of instances) then perl is the first thing I think of...
Unless the object model is regular and layered, then I think ruby.
Unless there is a need for blistering IO and syscalltastic goodness with function overloading, then C++
Unless there isn't a need for too many object tricks or the STL, then C.
All of the above languages have excellent tools, environments, and libraries. I think they've all got it made in the shade.
BTW, the easiest language to develop and troubleshoot is JavaScript (ecmascript). Tools like firebug make it stupid-easy. Of course, there's no regularized non-web environment for it; I've seen small efforts to that end but they always end up not going far. It's a real shame, IMHO. Prototyping, lazy-evaluating, duck typing, easy-to-read language... what's not to love?
I don't know *kicks dirt*
Re: XML??? Binary is faster! - yeahyeahyeah (Score:1, Insightful)
What advantages does XML provide at the expensive of data i/o speed loss?
The actual performance penalty comes from the actual parsing, which is of course slower than just memcpy()'ing memory-ready binary data into place. I have spent a whole lot of time on this performance issue and have found (the hard way) that the key to speeding this up lies in optimizing the xml document structure. Take it as a given that most xml tutorials advocate sub-par structure for the sake of simplicity.
Take a look at https://collada.org/public_forum/welcome.php [collada.org] for a good optimized xml-based format.
regards,