Beta

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

XML::Simple for Perl Developers

Zonk posted more than 7 years ago | from the weekend-project dept.

Perl 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."

cancel ×

186 comments

Sorry! There are no comments related to the filter you selected.

Sweet! (0)

bennomatic (691188) | more than 7 years ago | (#17877654)

Or in other words, XML-ent!

How is this news? (0, Redundant)

poopdeville (841677) | more than 7 years ago | (#17877964)

How is this news? XML::Simple is old. Really old. 1999 old.

Re:How is this news? (0)

Anonymous Coward | more than 7 years ago | (#17879330)

It isn't news. It was a stupid joke.

Who The Hell Still Uses Perl? (0, Flamebait)

Anonymous Coward | more than 7 years ago | (#17877660)

Outside of non-professional teenage Slashdot readers who still think the shitty Perl syntax is 'kewl', who the hell cares about the language anymore?

http://www.ruby-lang.org/en/ [ruby-lang.org]

Re:Who The Hell Still Uses Perl? (1, Flamebait)

shobadobs (264600) | more than 7 years ago | (#17877728)

Bah.

http://haskell.org/ [haskell.org]

Re:Who The Hell Still Uses Perl? (0)

Anonymous Coward | more than 7 years ago | (#17877804)

Pfft. Haskell is for wusses. [madore.org]

Re:Who The Hell Still Uses Perl? (0)

Anonymous Coward | more than 7 years ago | (#17877848)

So true man, Haskel is the rage amongst us bearded, short pants donning, backpack with both arms wearing grad students.

We talk about it all the time at our on campus barbecues when we aren't complaining about our advisors or playing frisbee golf.

Re:Who The Hell Still Uses Perl? (0)

Anonymous Coward | more than 7 years ago | (#17878146)

or ocaml.

Re:Who The Hell Still Uses Perl? (0)

Anonymous Coward | more than 7 years ago | (#17877792)

Outside of non-professional teenage Slashdot readers who still think the shitty Perl syntax is 'kewl',
Shitty... as opposed to what, PHP?

Re:Who The Hell Still Uses Perl? (-1, Flamebait)

Anonymous Coward | more than 7 years ago | (#17878216)

Shitty as PHP's syntax is, it's still better than perl's. It's irrelevant anyhow. It doesn't detract from Perl's shittiness in anyway.

Re:Who The Hell Still Uses Perl? (3, Interesting)

fyngyrz (762201) | more than 7 years ago | (#17878344)

Shitty... as opposed to what, PHP?

Well, certainly as opposed to Python, anyway. I went from perl to Python with a huge sigh of relief. I try to move a still-used perl script from perl to python once a week. Eventually I'll get them all, and I can leave the language behind. But I wrote tons of perl before I discovered Python and it is a long, long road to upgrade all that stuff. But every time I do one, I get a more maintainable, more english-like tool. Sometimes it takes me several minutes to even understand what the heck a perl script (even one of mine) is trying to do. Perl just... doesn't lead you to the most readable solutions. In fact, the better at it you get, the more obscure looking your programs get, it seems to me. That's an IMHO. :)

Anyway, if someone is looking for a scripting language today, Python is the cat's meow. Readable, sensible, extensible, flexible, well supplied with great libraries of functionality, powerful as hell, very easy to debug, not unreasonable in speed.

Re:Who The Hell Still Uses Perl? (0, Flamebait)

poopdeville (841677) | more than 7 years ago | (#17878434)

But I wrote tons of perl before I discovered Python and it is a long, long road to upgrade all that stuff. But every time I do one, I get a more maintainable, more english-like tool. Sometimes it takes me several minutes to even understand what the heck a perl script (even one of mine) is trying to do.

That's your own damn fault.

Python: syntactiacally significant whitespace..... (2, Funny)

fanatic (86657) | more than 7 years ago | (#17878454)

gack!

Re:Python: syntactiacally significant whitespace.. (3, Insightful)

Anonymous Coward | more than 7 years ago | (#17879506)

Oh yeah, it's just the absolute end of the world. Just a total show-stopper. After all, who would want readable, maintainable, consistent-looking code in a large team? What a disaster!

Re:Python: syntactiacally significant whitespace.. (0)

Anonymous Coward | more than 7 years ago | (#17879898)

http://www.bartleby.com/100/420.47.html [bartleby.com]

Consistency is great... if all your code does the exact same thing, the exact same way. Otherwise, it can be misleading, and the ability to express differing functions in differing formatting is an indispensable boon to clarity.

Re:Who The Hell Still Uses Perl? (1)

karthikg (322896) | more than 7 years ago | (#17878470)

I agree with you. In my case, I had a brief stop at TCL. I had a useful app which I moved to Python since I no longer want to make changes to it's TCL version. For those PERL scripts, I don't even care if they disappeared. In fact, I loved TCL lot more than Perl. Of course, when I first met Perl from the world of sh/C, it felt like heaven.

BTW does any of those complaining about Python, give one reason other than indendation, as a problem? (Oh come on, don't say some arbitrarily complain about slowness)

Recently I was studying about the next move.. no didn't find enough reasons to move/try Ruby.

Karthik

Re:Who The Hell Still Uses Perl? (4, Interesting)

texwtf (558874) | more than 7 years ago | (#17878814)

The fact that whitespace is dogmatized by the pyhon community makes the community
itself less attractive, and the language because of it. It sends the message that
it doesn't really matter what you want, the language is perfect and your code
is crap because you are too stupid to agree with how right the community is.

Guido could _easily_ put in some sort of pragma to allow other types of blocks, it's
only a matter of arrogance that stops him- coding with whitespace is the "right" way to do it.

There's also the matter of the parser. The last time I used Python everything was a syntax error, which gave little indication what was actually wrong with a piece of
code.

Re:Who The Hell Still Uses Perl? (3, Insightful)

rgravina (520410) | more than 7 years ago | (#17879318)

Guido could _easily_ put in some sort of pragma to allow other types of blocks, it's
only a matter of arrogance that stops him- coding with whitespace is the "right" way to do it.
There is are very good reasons for having indentation indicate a block.

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? (3, Insightful)

texwtf (558874) | more than 7 years ago | (#17879656)

There are very good reasons not to. Thus, dogma. My argument is "everyone else does it the other way, maybe being flexible would be good." Your argument is "I am right and my way is good, so there shouldn't be any other way". That's Guido's argument too.

Re:Who The Hell Still Uses Perl? (2, Insightful)

localman (111171) | more than 7 years ago | (#17879342)

In fact, the better at it you get, the more obscure looking your programs get

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 :) Still, it's my favorite language (I've only ever dug into java and c++ as alternates).

Cheers.

Re:Who The Hell Still Uses Perl? (1, Insightful)

Anonymous Coward | more than 7 years ago | (#17879404)

Python is English-like in the sense that VB.NET is English-like, which is to say, nothing at all like English. It's clumsy, unnecessarily verbose, overlogical and obtuse. There's no artistry to it; every Python program looks exactly the same regardless of functionality or intent.

Perl is for poets. Python is for autistic geeks who wish the world were expressed in maths.

Re:Who The Hell Still Uses Perl? (1)

abigor (540274) | more than 7 years ago | (#17879512)

The world actually is expressed in math. I hate to break it to you. And in places that matter (ie not your bedroom), Perl is dying as companies grow sick of the costs of maintainability. Welcome to the real world.

Re:Who The Hell Still Uses Perl? (1)

chromatic (9471) | more than 7 years ago | (#17879552)

Sometimes it takes me several minutes to even understand what the heck a perl script (even one of mine) is trying to do. Perl just... doesn't lead you to the most readable solutions.

Hasty generalization. Perl didn't lead you to the most readable solutions. That's fine; personal taste is a big factor in language preference. However, I (and plenty of other good coders I know) write maintainable Perl.

Re:Who The Hell Still Uses Perl? (5, Insightful)

BrianRoach (614397) | more than 7 years ago | (#17877858)

"Outside of non-professional teenage Slashdot readers who still think the shitty Perl syntax is 'kewl', who the hell cares about the language anymore?"

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:Who The Hell Still Uses Perl? (2, Interesting)

Lars512 (957723) | more than 7 years ago | (#17878124)

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".

I tend to use Python for most things, and consider it a general purpose language, suitable for all but performance critical tasks. I'd put Perl and Ruby in the same basket, as general languages with many libraries which just help you get things done. To me, these languages seem pretty interchangeable in this respect. In that case, the choice of which to use comes down to personal experience alone.

I'm curious as to whether you have a different opinion. Lets leave aside issues of syntax. What libraries or other features would you consider makes Perl the correct tool for a particular task? Are there particular tasks for which you use other scripting languages, in particular Python or Ruby?

Re:Who The Hell Still Uses Perl? (4, Insightful)

TheSkyIsPurple (901118) | more than 7 years ago | (#17878206)

I don't know about GP, but I've got a couple hundred hosts that have PERL installed, but not Ruby or Python, and getting those others installed would require alot of work. (some technical, given the age and OS on some of them... but mostly configuration management style issues)

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:Who The Hell Still Uses Perl? (1)

daliman (626662) | more than 7 years ago | (#17879280)

Hmmm... If you were feeling like playing devils advocate, you could suggest that the situation is the same with Windows... Of course I would never say such a thing!

Re:Who The Hell Still Uses Perl? (1)

TheSkyIsPurple (901118) | more than 7 years ago | (#17879596)

No kidding... there's a reason I'm doing a ton of VBScript work now... We've got several hundred of those as well, and guess what they all have? =-)

Re:Who The Hell Still Uses Perl? (0)

Anonymous Coward | more than 7 years ago | (#17878604)

As another poster mentioned, some of us work with systems that don't have Perl in the default install or as a vendor supported package.

I like Perl, Python, and Ruby. In our environment (OpenBSD & AIX), Perl is the language installed on the systems by default. It's on the vendor installation media. It is installed by default. Python and Ruby may be available as a package, but Perl is already there.

I may write Python and Ruby for things that stay my workstation, or on a for a specific task on server that for other reason we have explicitely added Ruby or Python, but if a program is going to run across all our machines it is written in Perl or shell.

Re:Who The Hell Still Uses Perl? (1)

JourneyExpertApe (906162) | more than 7 years ago | (#17878606)

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 .
I don't know about you, but I don't find " ." very readable. If that's what modern Perl syntax looks like, then I don't wanna go there.

Re:Who The Hell Still Uses Perl? (0, Flamebait)

Elias Israel (182882) | more than 7 years ago | (#17878628)

A well-designed programming language enables great programmers to create masterworks, encourages good programmers to produce great code, and makes bad programmers go looking for another profession.

Perl causes great programmers to produce good-enough code, makes good programmers produce bad code, and enables bad programmers to consider themselves software experts.

That said, anything that permits programmers in any language to work in XML is probably a good thing. Might teach them a few things about structure, flow, and interoperability.

Now you kids get off my lawn.

Re:Who The Hell Still Uses Perl? (4, Insightful)

andres32a (448314) | more than 7 years ago | (#17878008)

Slashdot.org!!

Re:Who The Hell Still Uses Perl? (-1, Troll)

Anonymous Coward | more than 7 years ago | (#17878050)

related to this, is the question of why vlad farts so much. i honestly don't know. many people have said that he has a diet of nothing but raw lard and baked beans, that would really explain alot. i do know for a fact that vlad farts about 15 to 100 times the amount that a normal human does, that is pretty sick imo. and what's worst is that he claims to be a catholic, yet he farts basically constantally. would somebody care to explain that to me? no? i didn't think so

Re:Who The Hell Still Uses Perl? (0)

Anonymous Coward | more than 7 years ago | (#17878866)

I think it involved goatse-like accident with a bolwing pin. Some people claim it wasn't actually an accident.

Hello, AC (2, Insightful)

Scareduck (177470) | more than 7 years ago | (#17878184)

There's a reason they're called "Cowards". Those of us who've been around a while know that there are all kinds of languages out there, and plenty of them can be used to write good code. The real problem with Perl is that Larry Wall is slowly losing his mind, adding features that nobody asked for; a good example is the new, backwards-incompatible regexps. (Don't go off that there'll be a compatibility mode; that's beside the point. The hubris needed to upend this core part of the language is pretty astonishing.) Also, he seems to be spending a lot of time with the Parrot rehosting, something else that is (perhaps) of dubious value. The changes are so orthogonal to what I do with Perl (hello, how about faster OO calls?) I have to wonder if there'll ever be a reason to switch to Perl 6. (Perhaps someone out there who knows more can comment.)

Re:Hello, AC (4, Insightful)

nuzak (959558) | more than 7 years ago | (#17878258)

> The hubris needed to upend this core part of the language is pretty astonishing.

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.

Hello Nuzak (1)

symbolset (646467) | more than 7 years ago | (#17879352)

Nobody is supposed to remember SNOBOL. There was no SNOBOL.

Re:Hello, AC (2, Insightful)

Watson Ladd (955755) | more than 7 years ago | (#17878364)

I think the regex syntax change is aimed at reducing the line-noise quality of regexes, as well as making them more expressive. The interpreter change is mostly aimed at pooling the skills of the Perl, Python, and Ruby communities. Even if it looks like a lot of effort now, it will pay off a lot later.

Re:Hello, AC (4, Insightful)

VGPowerlord (621254) | more than 7 years ago | (#17878688)

What I find annoying is that core language features are changing operators for no reason other than to change operators.

Example: -> is changing to . The reason given is

-> becomes ., like the rest of the world uses.
Which also forces . to change to ~ (also .= is now ~=)
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.

Perl6 (1)

fanatic (86657) | more than 7 years ago | (#17878736)

I'm hoping I die and/or retire before perl5 is discontinued.

Re:Hello, AC (1)

larry bagina (561269) | more than 7 years ago | (#17878898)

I was looking forward to perl 6 until I heard about that.

Re:Hello, AC (2, Informative)

chromatic (9471) | more than 7 years ago | (#17879528)

What I find annoying is that core language features are changing operators for no reason other than to change operators.

The Apocalypses and Synopses (which somehow you managed to quote without reading the surrounding context) explain the reasons for the changes.

Re:Hello, AC (1)

VGPowerlord (621254) | more than 7 years ago | (#17879996)

Several operators have been given new names to increase clarity and better Huffman-code the language, while others have changed precedence.
is not a strong enough justification to change operators in a non-backward compatible way. It takes everything you've learned and throws it out the window. What is the incentive to me, as a developer, to learn Perl 6 over another language, since I have to relearn everything from scratch?

Also, why continue to call it Perl if the entire language's syntax changed? It would be like Microsoft calling what is now C# "Visual C++ 7," except that C++ has an ISO standard.

P.S. I'm aware that Microsoft still makes Visual C++ and that the latest version is 8.

Re:Hello, AC (1)

chromatic (9471) | more than 7 years ago | (#17879546)

The real problem with Perl is that Larry Wall is slowly losing his mind, adding features that nobody asked for; a good example is the new, backwards-incompatible regexps. (Don't go off that there'll be a compatibility mode; that's beside the point. The hubris needed to upend this core part of the language is pretty astonishing.)

I assume you've never used Perl 6 rules. I have. They are so much more powerful and usable than Perl regexes that they deserved a different name.

Also, he seems to be spending a lot of time with the Parrot rehosting, something else that is (perhaps) of dubious value.

No, he's not. That's Allison and Patrick and me. What gave you the idea that Larry worked on Parrot?

Re:Who The Hell Still Uses Perl? (1)

vandan (151516) | more than 7 years ago | (#17879848)

Glad you asked. I do [homelinux.org] . And I like it. Got a problem with that?

one question (-1, Flamebait)

Anonymous Coward | more than 7 years ago | (#17877674)

does it also tell Zonk where to shove it?

Are you serious? (-1, Troll)

Umbral Blot (737704) | more than 7 years ago | (#17877774)

Perl + XML what could possibly go wrong? (With Perl by itself you were only 95% likely to end up with a unreadable mess, now with XML we can push that up to 100%. Oh boy!)

Re:Are you serious? (0)

Anonymous Coward | more than 7 years ago | (#17877850)

You, sir, sound look someone who does not understand Perl. Decent Perl looks like an unreadable mess only to VBScript programmers.

Re:Are you serious? (0)

Anonymous Coward | more than 7 years ago | (#17878100)

Why is there always so much Perl bashing that goes on here. You can make any languages code look like a steaming pile of crap. And honestly I probably had some of the same sentiments before I started my current job, where I've done quite a bit of development in Perl. Its the right tool for the job, and I do have to take a little extra time when writing my code to make it as readable as say Java or C++, but really not all that much more. Be a smart programmer and you wont have to worry about how ugly the code is, its only as ugly as the person writing it.

Bah, who the hell still uses perl? (-1, Troll)

Anonymous Coward | more than 7 years ago | (#17877776)

Professionals use python

http://www.python.org/ [python.org]

Re:Bah, who the hell still uses perl? (5, Insightful)

ThatDamnMurphyGuy (109869) | more than 7 years ago | (#17877798)

No, professionals write good code, regardless of the language. There is just as much shitty Python/Ruby out there as there is Perl.

Re:Bah, who the hell still uses perl? (1, Troll)

LM741N (258038) | more than 7 years ago | (#17877830)

Yes, but at least with Python you can read and understand the shit- and then fix it if need be.

Re:Bah, who the hell still uses perl? (3, Insightful)

soapbox (695743) | more than 7 years ago | (#17877894)

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.

Re:Bah, who the hell still uses perl? (2, Funny)

KermodeBear (738243) | more than 7 years ago | (#17878006)

As true as that may be, I have never heard of any other language be referred to as a "write only language".

Re:Bah, who the hell still uses perl? (4, Insightful)

Jah-Wren Ryel (80510) | more than 7 years ago | (#17878048)

As true as that may be, I have never heard of any
other language be referred to as a "write only language".
The only point that citing your personal ignorance makes is that you are ignorant. [wikipedia.org]

Re:Bah, who the hell still uses perl? (0, Flamebait)

KermodeBear (738243) | more than 7 years ago | (#17878092)

Ah, and now I can say that I've only known three languages to be referenced to as write only - Perl being one of them (TECO and APL being the other two).

Regardless, even though the reputation is a shared one that doesn't make it a good thing.

Re:Bah, who the hell still uses perl? (5, Insightful)

Anonymous Coward | more than 7 years ago | (#17879082)

So you have never used APL, eh?

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, ...), Basic, C, C++, Fortran (66,77,90,95), Gauss, Icon, Java, maxima/macsyma, mumath, pascal, perl, prolog, python, ruby, R, VB and probably a few I forget in there. The big idea I have learned is to never force fit a tool to a problem. Select the right tool for the right problem. And go from there.

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, ...). It is not the perfect language for everything though, there are some missing bits.

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 ... spent 15 years developing Fortran code. May it never reach 16 years.

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.

Underestimating Java (2, Interesting)

GunFodder (208805) | more than 7 years ago | (#17879368)

Perl is a good development language. I especially appreciate the transparency of scripting languages - if something goes wrong I can examine the source immediately. But I think you underestimate the power of Java. CPAN is good, but the resources available to a Java developer are even more extensive, thanks to the combined efforts of the major software players and the open source community. Java-specific development tools are leaps ahead of most other languages. When a serious amount of effort is required to solve an problem then it makes sense to invest time in a tool that make complex systems easier to develop and troubleshoot.

Indeed. (2, Insightful)

Ayanami Rei (621112) | more than 7 years ago | (#17879934)

Java is well-suited for large projects with fairly well defined requirements (and potentially complex interactions between objects/components).

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:Bah, who the hell still uses perl? (0)

Anonymous Coward | more than 7 years ago | (#17879984)

No, professionals don't work as a software programmer/engineer/whatevertitleyouwanttoglorifyi twith, that is a blue collar job nowdays :) Get with the times, move on :)

Re:Bah, who the hell still uses perl? (0)

Anonymous Coward | more than 7 years ago | (#17877892)

Professionals use Perl and Ruby.
Idiots Indentation Nazis use Python.
Python is as a Python will always be, slow and constricting.
Coding in Python is like baby talking to a 2 year old. It's f*cking annoying.
Go back to Basic or Turtle!

XML::LibXML is where it's at (5, Informative)

teknomage1 (854522) | more than 7 years ago | (#17877786)

XML::LibXML is where it's at, it is a) quite a bit faster and b) has a sensible interfce rather than giving you useless empty hashrefs in the middle of a tree.

Re:XML::LibXML is where it's at (4, Informative)

rvalles (649635) | more than 7 years ago | (#17879518)

I agree completely. I've used both recently (and XML::Xpath) and XML::LibXML is much more powerful and sane, while at the same time it is about as easy to learn. There's the added advantages that being just LibXML bindings what's learned is useful in other programming languages, and that nodes are referred using Xpath, which is a really powerful and useful W3C standard that, again, is worth learning.

Propogation (0)

Anonymous Coward | more than 7 years ago | (#17877816)

Great, the XML bloat and slowness continues to propogate out of document storage...

Re:Propogation (0)

Anonymous Coward | more than 7 years ago | (#17877926)

It's "Propagation". Learn propa English!

Re:Propogation (0)

Anonymous Coward | more than 7 years ago | (#17878020)

Sorry for the mistake. I'll learnd da propa English from you.

It is too bad that you can not correct submissions. But, hey, this *IS* slashdot.

good lord... (0, Insightful)

Anonymous Coward | more than 7 years ago | (#17877902)

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? (4, Insightful)

cliveholloway (132299) | more than 7 years ago | (#17877978)

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:What? (1)

archen (447353) | more than 7 years ago | (#17878086)

I'm a YAML convert myself. I used to use XML::Simple quite often for configuration files but generally wasn't to happy with the readability of what it generated. YAML by contrast was pretty easy to read and write your configs by hand if you wanted (a pain with XML). However XML isn't going anywhere soon. In some industries XML is just now starting to grab attention for interoperability and I've had to deal with XML stuff that was just handed to me more and more. In that sense XML::Simple has made my life much easier.

Re:What? (1)

colinbrash (938368) | more than 7 years ago | (#17878106)

Ignoring the YAML/XML thing, this is still pointless. How many people using Perl don't know how to use CPAN? How many people using Perl can't understand CPAN docs? How many people reading the XML::Simple docs need further help? It's called XML::Simple for a reason! It really IS simple.

Re:What? (0)

Anonymous Coward | more than 7 years ago | (#17878724)

Ignoring the YAML/XML thing, this is still pointless. How many people using Perl don't know how to use CPAN? How many people using Perl can't understand CPAN docs? How many people reading the XML::Simple docs need further help? It's called XML::Simple for a reason! It really IS simple.

What are "CPAN docs"? If you can figure out how to install one module you can figure out how to install them all. Also since you know how to read the docs for XML::Simple you know how to read them for the other one as well.

Perhaps XML::Simple is easier to use, but your line of reasoning is like saying it is harder to buy a Ford than a Chevy so buy the Chevy. Built on extremely flawed reasoning.

Re:What? (1)

colinbrash (938368) | more than 7 years ago | (#17878782)

What are "CPAN docs"? If you can figure out how to install one module you can figure out how to install them all. Also since you know how to read the docs for XML::Simple you know how to read them for the other one as well.

Perhaps XML::Simple is easier to use, but your line of reasoning is like saying it is harder to buy a Ford than a Chevy so buy the Chevy. Built on extremely flawed reasoning.


I'm not saying buy anything or use anything or whatever. I'm just saying the article is pointless.

CPAN docs are the documentation that goes along with a module. In this case:

http://search.cpan.org/~grantm/XML-Simple-2.16/lib /XML/Simple.pm [cpan.org]

Yes, if you can install one perl module, you can install any other (to a degree). So what's the point in explaining how to install a perl module? Point the reader to one of the millions of other places that already explain it.

But more importantly, the XML::Simple documentation is very good and very easy to understand. Why is there an article that basically regurgitates the documentation? Just point the reader to the documentation instead!

I'm afraid I don't understand your analogy at all.

Re:What? (1)

Cthefuture (665326) | more than 7 years ago | (#17878354)

Are there XML-RPC equivalents for YAML and/or JSON? Although I'm sure it would be easy to create something I am just wondering if there is any sort of standard.

How do you process YAML or JSON in Javascript (eg. in a browser)? Most browsers have built-in support for processing XML.

Re:What? (1)

maxume (22995) | more than 7 years ago | (#17878550)

eval('(' + json + ')'). There are libraries if you don't trust your source:

http://www.json.org/js.html [json.org]

is one.

Re:What? (1)

hoggoth (414195) | more than 7 years ago | (#17878810)

> How do you process YAML or JSON in Javascript (eg. in a browser)? Most browsers have built-in support for processing XML

Wow, that must be great having support for XML built into Javascript.
Oh, by the way, JSON is expressed in valid Javascript syntax. That means JSON is already Javascript. No libraries or support necessary.

Sorry for the snarkiness. 'Been struggling with some XML code. That always puts me in a bad mood.

Re:What? (5, Funny)

jtolds (413336) | more than 7 years ago | (#17878358)

"Leverage the power of XML" by deprecating it wherever you can for a more sensible cross platform format.
</rant>


1. Advocate XML deprecation.
2. Use XML style conversation markers.
3. ???
4. Profit!!!

Re:What? (1)

cliveholloway (132299) | more than 7 years ago | (#17878618)

I TELL YOU IT'S A FRICKIN' PLAGUE!!!

lameness filter encountered - need this line to post...

Re:What? (1)

Kangburra (911213) | more than 7 years ago | (#17878582)

XML is a steaming, clumsy overrated turd
You don't like it much then!? ;-)

Re:What? (1)

cliveholloway (132299) | more than 7 years ago | (#17878648)

Can you tell I was in a bad mood? :)

No, I understand that it *can* be well used, just that for 90% of the applications it *is* used for appear to only be using it because the author once read somewhere that leveraging XML was the way forward. If you're dealing with data storage only, XML is always the wrong answer(*).

cLive ;-)

(*) unless the question is, "What is the worst format to store configuration data in?" :)

Re:What? (1, Funny)

Anonymous Coward | more than 7 years ago | (#17878926)

(*) unless the question is, "What is the worst format to store configuration data in?" :)

I can think of worse. How about a flat namespace populated with pairs of the form (name, number). After that list, you can have a giant (about 2^19940 bytes long) of 8 byte values, related to the pairs as follows: the key with name 'pair' has the value stored in the M(number)th bin, where M is the Mersenne Twister function. [wikipedia.org]

Re:What? (1)

sporb (710088) | more than 7 years ago | (#17879156)

See -> Perl::Troll

is this a strawman attack? (1)

GunFodder (208805) | more than 7 years ago | (#17879400)

I agree that the article is pointless. XML::Simple is the oldest Perl XML library in existence, and there are better alternatives available. How does YAML::Syck hold up against XML::LibXML for performance? Is the syntax as easy to use as XML::XPath? Who else uses YAML? I don't want to invest my time in a data format that no one else uses.

Re:is this a strawman attack? (1)

cliveholloway (132299) | more than 7 years ago | (#17879532)

I don't know but I'm sure you can Benchmark them :) Even if no one uses it, your own apps will be faster. All depends what area you work in, I guess.

Thanks (1)

goombah99 (560566) | more than 7 years ago | (#17879514)

Hey thank you for pointing this out. I did not know about this. JSON and YAML are pretty nice.

Re:What? (1)

castrox (630511) | more than 7 years ago | (#17879908)

Given that XML has become a bit of a standard in business, it makes sense to use it to be able to share data between applications written in different languages. Now, I don't know the status of YAML in e.g. Java or C++, but unless they have good parsers for it I reckon I'd choose XML for the task simply because it's sufficiently clear, people know how to use schemas, and so on.

Re:What? (1)

fatphil (181876) | more than 7 years ago | (#17880184)

No, you obviously don't understand, "Because XML is after all the standard for this sort of thing,"

FatPhil

More like "XML for Simple Perl Developers"... (0)

Anonymous Coward | more than 7 years ago | (#17878010)

who can't RTFM!?!!

That would be in ebcdic (0)

Anonymous Coward | more than 7 years ago | (#17878012)

More bullshit from the big blue
Oh yeah, thats right, the Linux fanboy on some crazy patent free westworld trip!

Perl is for guys who live with their mum

Perl is for people who think how they think is how we all think
AMPERSAND, WHY YES AMPERSAND!
Of course you dummy

XML?
XML is some stuff one of those deranged geeks COULD decode if the shit hit the fan
XML is the ANGLE BRACKET DAWN OF A NEW AGE; A NEW ROBOT AGE WHERE WE WILL LIVE IN TOTAL WORLD PEACE

Perl was the fucking bastard son of AWK
Perl is Sooo 1995
Where the fuck is Perl 6?
Oh quick bolt on some OOPS stuff, I got an interview with Sun Microsystems tommorrow
Thats right Mr President sir, Perl will make our willys larger than Big Bad Bills
WE WILL DRENCH THEIR FACES IN OUR SUPER CUM

Fuck we can't give it away man, free as in out-of-date BEER

PS Has anyone confirmed Perl is dead yet?

Re:That would be in ebcdic (1)

daeg (828071) | more than 7 years ago | (#17878594)

Your post reads like a badly written Perl script, albeit with less punctuation.

what a coincidence (re: XML::Tiny) (1)

toby (759) | more than 7 years ago | (#17878074)

I just today noticed the announcement of XML::Tiny [cpan.org] .

hmm (2, Informative)

XanC (644172) | more than 7 years ago | (#17878110)

It only claims to support a subset of XML, and of course it is called "Tiny", so I guess I can understand not supporting CDATA or attributes (...maybe). But for a ">" in a CDATA block to cause it to fail? It doesn't seem very useful.

Re:hmm (1)

orkysoft (93727) | more than 7 years ago | (#17878362)

It's still useful if you're only using it to read a limited kind of files, such as configuration files that were generated by the program itself. Of course, when the program needs to parse XML files generated by other programs, a more comprehensive module is needed.

Re:what a coincidence (re: XML::Tiny) (1)

Saint Stephen (19450) | more than 7 years ago | (#17878380)

Flame me if you want, but that guy's comments at the end of his README, and the link to his Wishlist page, are just too much. Chime in if you read it. /rolls eyes

A good tool for small tasks, but... (2, Interesting)

Scareduck (177470) | more than 7 years ago | (#17878142)

... utterly useless for anything of real size. XML::Simple is a huge memory sink, because, as mentioned elsewhere, it insists on generating full hash and array representations of the source XML text. This seems to be the side effect of taking too seriously a lot of Perl advice enthusiastically handed out in the older documentation. (Put file text into a huge array! Don't close your file descriptors!) The rest of us know better.

I came in here to say this (4, Interesting)

Wee (17189) | more than 7 years ago | (#17878456)

Was exactly what I was going to say. I've used XML::Simple a lot, but only for reading in small documents, like config files. It works well for that. But I'd never use it on something that was bigger than, say, 100K. It's too slow and resource intensive. It does, however live up to its name. It's a very simple interface to an XML doc.

One thing I user it for was representing a database in XML. Once I had the DB layout in a datastructure, it was one line to print it out. Of course, this was before I knew about DBIx::XML_RDB...

-B

Re:A good tool for small tasks, but... (1)

localman (111171) | more than 7 years ago | (#17879302)

The rest of us know better.

Hey now, it depends on the context. Sometimes it is good to just put text into a huge data structure. Sometimes it's not. In the end, a smart programmer who understands the issues is better than a rule.

Cheers.

Simple is not good (2, Informative)

MarkKnopfler (472229) | more than 7 years ago | (#17879096)

In my personal experience, Simple is probably the worst implementation of an XML parser in perl. For a simple implementation, I have found Twig to be much more useful, sensible and fast.

XML data structure serialization (2, Informative)

barnacle (522370) | more than 7 years ago | (#17879494)

This is the same approach that is built-in to the qore language http://qore.sourceforge.net/ [sourceforge.net] .

It makes it really easy to manipulate data in XML format.

However, qore supports deserialization of mixed text and data and multiple out-of order elements, XML attributes (imagine parsing a docbook file for example), as well as serialization (conversion of a qore data structure to an XML string) with the same features.

The same limitations regarding streaming input and very large files affect this approach, but in all other common cases, it makes it really remarkably easy to manipulate and create data in XML format using this approach.

(Qore also supports JSON with the same approach -- serialization and deserialization between JSON strings and qore data structures...)

thanks,
David

XSLT can't do arithmetic? WTF? (2, Informative)

johnny99 (45334) | more than 7 years ago | (#17879602)

The author of that article says you'll want to use the magic of perl and XML::Simple because "XSLT can't do arithmetic" and proceeds to do magical things like increase numbers by 20%.

That's just ... bizarre. Of course you can do that with XSLT! <xsl:value-of select="whatever * 1.2">

Then he formats a number -- because XSLT, of course, doesn't have a format-number() [w3schools.com] function.

Next article -- why you should commute to work in an airplane because, as everyone knows, cars can't turn corners.

XML??? Binary is faster! (0, Offtopic)

mrnick (108356) | more than 7 years ago | (#17880068)

These comments are based on C++, though i have used Perl I have been doing much more C++ coding lately.

The XML files are text based. Text I/O has to be read in sequentially whereas you can write out an entire block of allocated memory to the disk in binary format. The advantages of this is that you can read & write that data to and from disk 50 to 100 times faster than reading it in sequential from a text file.

What advantages does XML provide at the expensive of data i/o speed loss?

Nick Powers
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?
or Connect with...

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>