XML::Simple for Perl Developers
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."
Bah.
http://haskell.org/
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.
Stop intellectual property from infringing on me
No, professionals write good code, regardless of the language. There is just as much shitty Python/Ruby out there as there is Perl.
Yes, but at least with Python you can read and understand the shit- and then fix it if need be.
"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.)
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--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.
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?
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 or JSON instead. XML is a steaming, clumsy overrated turd. I benchmarked XML::Simple against YAML::Syck - 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>
-- Trinity in high heels carrying a whip: The donimatrix - there is no spoonerism
As true as that may be, I have never heard of any other language be referred to as a "write only language".
Love sees no species.
Slashdot.org!!
When information is power, privacy is freedom.
I just today noticed the announcement of XML::Tiny.
you had me at #!
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.
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?
... 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.
Dog is my co-pilot.
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.)
Dog is my co-pilot.
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.
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.
I've fallen off your lawn, and I can't get up.
gack!
"that's not encryption - it's a new perl script that I'm working on..." - from some Matrix parody
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
Ash and Hickory, straight-grained and true, make excellent bludgeons, dandy for the cudgeling of vegetarians.
Your post reads like a badly written Perl script, albeit with less punctuation.
If you can read this sig, you're too close.
I'm hoping I die and/or retire before perl5 is discontinued.
"that's not encryption - it's a new perl script that I'm working on..." - from some Matrix parody
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.
So you have never used APL, eh?
...), 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.
...). It is not the perfect language for everything though, there are some missing bits.
... spent 15 years developing Fortran code. May it never reach 16 years.
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.
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.
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!
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.
In fact, the better at it you get, the more obscure looking your programs get
:) Still, it's my favorite language (I've only ever dug into java and c++ as alternates).
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.
Nobody is supposed to remember SNOBOL. There was no SNOBOL.
Help stamp out iliturcy.
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.
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.
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.
This is the same approach that is built-in to the qore language http://qore.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
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!
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.
Hey thank you for pointing this out. I did not know about this. JSON and YAML are pretty nice.
Some drink at the fountain of knowledge. Others just gargle.
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.
how to invest, a novice's guide
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? =-)
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%.
... bizarre. Of course you can do that with XSLT! <xsl:value-of select="whatever * 1.2">
That's just
Then he formats a number -- because XSLT, of course, doesn't have a format-number() function.
Next article -- why you should commute to work in an airplane because, as everyone knows, cars can't turn corners.
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.
Glad you asked. I do. And I like it. Got a problem with that?
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*
THIS THING CAN TURN ON A DIME, MACROSSZERO STYLE ALSO FUCK BETA, ~NYORON
What advantages does XML provide at the expensive of data i/o speed loss? Most xml parsers I have used had the option to read the complete file into memory in large chunks, and perform the actual parsing on the memory stream. So there is no performance penalty compared to binary file loading in terms of I/O.
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 for a good optimized xml-based format.
regards,
I recommend you start a yahoogroup for the discussion of Python. The same applies to YAML advocates too, of course. Exchange a few snippets of code/data.
Hopefully you'll then realise how non-portable a white-space-based convention is.
Also FatPhil on SoylentNews, id 863
Can't tell if this is a joke or if you're serious. ASCII-based formats solve the issue of data transmission between two unknown sources.
binary formats suffer from the issues of data representation and Endian-ness. Are your Integers 64-bit or 32-bit? Did you write your values with a Power-PC or with an Intel-based processor?
Like it (or not), XML is becoming the defacto standard for data representation. I'm dealing with this in embedded CIM implementations. Are there better parsable formats? Possibly. But none that are so universally accepted.
As they say, "The great thing about standards is there's so many to choose from!".
To Copy from One is Plagiarism; To Copy from Many is Research.
> PERL
Just an fyi ... Perl isn't an acronym and that capitalization is used to recognize inexperienced Perl programmers. My guess is you don't like Perl becuase you never really got into it. Perl vs Python vs Ruby vs Pike is a pretty silly thing to argue. It's largely a matter of preference like vim vs emacs. So the whole argument is ridiculous...
But Perl isn't an acronym.
Imagine if you weren't allowed to use roads because a bus company complained about your driving 3 times. --skunkpussy
I used XML::Simple in a script I wrote to grab data from my garmin GPS to use at http://www.gpsvisualizer.com/ Worked great without a lot of extra stuff to learn for a simple task.
Learn how sweet PHP is
Though a bad coder can write Perl code hard to understand (not that hard anyway), thanks to its freedom, Perl is by far the imperative language easiest to read and to maintain.
This requires a decent coder of course, but this is easy accomplished too, since the bad ones have all gone with PHP.
I try to keep my code as readible as possible, and when I do write something that's rather dense and "Perlish", I comment it. But CPAN is what keeps me in Perl; there's just too much there to easily give up.
I'm sure Python and Ruby, etc. are great languages, but I see no compelling reason to give up Perl just yet. I'm on the fence with Perl 6 -- if Parrot allows CPAN modules to be used by other scripting languages, I might learn Ruby if I can leverage existing Perl modules.
I would bet the same thing would have happened if you had rewritten all of your code over again, in Perl or any other lang. I think you are confusing the fresh start that a new lang is giving you, with the ability to write more readable code. More and more, when I see any post, no matter how well reasoned at acts like any lang, scripting or otherwise is "BAD" makes me thing the person saying that is just trying to blame their own issues on a source outside of themselves. It is amazing how many otherwise intelligent people make this mistake. I did the same thing with PHP, the attitude of some of its core developers sickens me and there is a lot about it that feels slapdash to me as a result, however, it does make a lot of tasks very easy, and its default performance isn't too bad. But then people expect it to do everything *BE* scalable etc when scalable is ALWAYS a lot of work and effort no matter what lang platform you are using. Try to deny that! In other words you can misuse any tool and blame it on the tool.
As for the topic of this post, what are we talking about shoes? Are you kidding? I, like most people who got into tech, got into it because we appreciate a scientific point of view. We like thinking that way. This subject, "Who The Hell Still Uses Perl" sounds like it could as easily be who still wears red or something.. If you want to talk to the best of us, then don't screw yourself over right away with this kind of obviously emotional tag right off.
I think you mean Pathologically Eclectic Rubbish Lister.
;-)
IIRC Larry Wall actually coined that phrase too
> Perl is dying as companies grow sick of the costs of maintainability.
They sure as fuck aren't moving to a language that doesn't even have the same capabilities of use strict;. Yeah, we all just love how python ignores typos in variable names because it has no concept of a declaration.
Done with slashdot, done with nerds, getting a life.
Python's a lot better about locating errors than it was in the 1.x series, including whitespace ones. I'd try it again if that's all that got to you. The whitespace thing still occasionally irks me, but it's pretty evenly balanced by not having to use semicolons.
I find python's "half open ranges" and lack of variable declaration far more irritating than anything else.
Done with slashdot, done with nerds, getting a life.
The fact that whitespace is dogmatized by the pyhon community makes the community
itself less attractive, and the language because of it
This put me off python for a long time, too. "Whitespace is not actually evil--it is just misunderstood" is a lesson I learned from SGML-based text processing, where concepts like "ignorable whitespace" reflect the reality of how strangely humans interpret such things.
But once you get over the fact that a fundamental aspect of the language's structure is based on a character set that many text editors feel free to misrepresent to the user, you'll find that python has some signficant benefits over Perl, especially for application prototyping and exploratory coding. For pure text processing I'd still choose Perl, and Perl still leads in terms of number of libraries to handle common and even pretty uncommon tasks, but python's native OO syntax and good GUI support via wxPython and the like make it a useful tool for a developer to have.
Blasphemy is a human right. Blasphemophobia kills.
I'm a bit leery of installing it on a machine where I do have root access. The incomprehensibility of the install code, plus the fact that it comes from IBM (which may be a bit better than MS, but does have a bit of history
Those who do study history are doomed to stand helplessly by while everyone else repeats it.
Oh boo hoo, he hasn't heard of these two random other languages, one of which is obscure and the other long-dead. He must really be an incompetent fool: anyone who wasn't around in the days of TECO is. What was your point again?
My point was that proof by regurgitated insult isn't any proof at all.
When information is power, privacy is freedom.
XML::Gay
I guess we're still waiting for that "well-designed programming language". :D
the good ground has been paved over by suicidal maniacs
I code in Perl for a living. I code in Python and Ruby for fun.
While many languages have excess baggage (like semicolons) simply because their designers didn't want to stray too far from the languages that inspired them, Perl is the only language out there that is made up entirely of this baggage. It's a Frankenstein's Monster of dead language ideas.
Also, Perl, above all other languages I have used, Perl seems to have been been designed with the philosophy "complexity is good." Today, this philosophy is almost universally recognized as being completely backward in the software engineering world.
Perl's criticism is well-deserved. The only real advantages of Perl over the other high level languages in its space are execution speed, availability of skills, and a large module library. It doesn't take a genius to realize that Perl's lead in these areas is shrinking rapidly.
And if you agree that complexity is bad, surely you realize that Perl encourages it, while the other languages do the opposite.
A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
I'm curious: What hosts are you writing for which don't support modern high level languages (without excessive effort)?
A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
Only a PERL programmer would think that is a good idea
A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
XSLT is disqualified because it's impossible to do anything of any complexity in it without going insane.
Not only is the syntax horendously complex, but there are major misimplemented features that force strange and illogical workarounds, but people used to real programming languages have a really hard time grasping the template style leading to even more frustrations.
XSLT is a complete paradox, on one hand it's supposed to let non-programmers manipulate xml, but at the same time it's so hard to use that programmers can't use it.
I'd rather use a real programming language that I already know and manipulate the data with that, thank you very much.
-- To dream a dream is grand, but to live it is divine. -- Leto ][
Because you see, despite the fact that programmers like to pretend that they're supremely rational they're actually as faddish as a bunch of teenagers.
(bites)
Having used PHP, Perl, SQL HTML, and CSS on various projects all at once, I have to say that whilst the syntax of Perl is fairly bad, once you mix php script with html and SQL you end up with an unreadable mess. There is no escape from this. I have reformatted my code any number of ways to get "easy to read" code out of php, and I can't do it.
The down side of this is that I tend to write small easy tasks in php and big complex tasks in Perl. Simply because Perl is able to be formatted in a reasonably readable format.
Yes I will admit that Python lays out better than Perl. I just have allergies to white space dependant languages. I've tried. $DEITY knows. But I cannot get the hang of formatting my code the "Python Way". This is my shortfalling, not Python's.
A sig is placed here
To display how futile
English Haiku is
Yep, XML::Twig is the thing to use - gives you the efficiency of a stream/event based parser and the convenience of DOM/XML::Simple style access.
XML::Simple is a toy in comparison.
Non-portable? I'm not sure how whitespace changes from platform to platform. Am I misunderstanding something there? Anyhow, it doesn't matter whether a block is indented by a tab, one space, two, four etc. as long as everything at that level is indented consistently. Does this help?
Even if code sent through Yahoo groups/in the body of an email can't be easily copied-pasted-and-compiled (is that what you are referring to?), I don't really see that as a huge disadvantage. You could just attach the file.
I'm open to suggestion - perhaps those that like freedom in indentation have a point, but I just can't see it. Trade a penny in freedom of block layout and get back a pound in consistency and readability.
Perl Expanded a Regex Language too, but that still doesn't make it an acronym.
how to invest, a novice's guide
wxPython I give you (and I throw in py2exe for free, because it's useful), but "native OO syntax"... not really so much. Declaring parameters in signatures is nice (except that you don't get the invocant), but static default values, ouch.
how to invest, a novice's guide
I don't realize that. Can you explain?
All I know is that it's impossible for Chinese people to communicate because someone who never learned the pictographs can't write a post-modern novel within a week of starting to learn Mandarin.
how to invest, a novice's guide
Any decent editor can reindent code. No editor can improve poor symbol names. The latter has much, much more to do with maintainability than indentation.
how to invest, a novice's guide
See the INSTALL_BASE argument to MakeMaker.
how to invest, a novice's guide
You've not started a yahoogroup, and seen what breaks. You've not even hunted
out any yahoogroups for python to see what goes wrong. And yet you have the
gall to question what I've previously stated? Sheesh, the impudence.
Your wish for "indented consistently" is granted.
Unfortunately for you the indentation level is 0 everywhere.
Still think your python code will work if posted there?
Not every medium is whitespace friendly. This is why things like quoted-pritable
were invented, and things like base64 and uuencode specifically avoid the space
character.
Also FatPhil on SoylentNews, id 863
I wonder what's going on here?
Those who do study history are doomed to stand helplessly by while everyone else repeats it.
Not to mention you'd probably indent the code in any other language, python just gets rid of the extra braces.
... as one of more than one ways to do things. Unfortunately, every Perl program I have seen (with the merciful exception of POPFile) picks one of the other ways. TMTOWTDI, don't you know.
The problem with Perl isn't the language. OK, let me amend that: s/ (t)/just $1/. Its that the culture which surrounds the language encourages practices which are at odds with maintainability. You can't seperate Perl code from Perl coders, and Perl coders are, to a disturbing degree, prone to creating unmaintainable cruft with copious use of syntatic sugar which is actually disguised cyanide. Perl would be better off if some things which are syntactically allowable were banned forever. Here's a couple:
* copious use of default parameters (a wonderful way to introduce bugs into the program by accidentally overwriting one when inserting a new line of code between two sections of code which do not look obviously related)
* $_.=$& Code this obtuse needs to be discouraged, not encouraged. Its powerful, but totally obtuse, and programmer brain time is more important than finger time, which unfortunately Perl has decided to optimize for. (Incidentally: it appends the last regular expression match to whatever string you were operating on. I think.)
* Multiple methods of passing arguments to functions. (I have come across code which uses more than three in a single source file.) Function prototypes are like seatbelts. I know you think you're smart enough to not cause an accident. Statistically speaking, you're not. Buckle the heck up.
Help poke pirates in the eyepatch, arr.
You need a fairly recent version of ExtUtils::MakeMaker. Perhaps upgrading that (as root) will help. Otherwise, the PREFIX option exists in older versions, but it doesn't work the way almost everyone assumes it does.
how to invest, a novice's guide
Actually, as long as the sender and receiver are in C, XML has not been the bottleneck for me yet. I do have one Perl XML sender (using XML::Simple) which is a bottleneck.
One way to solve the endianness problem is with the functions in byteorder(3). Another is to prefix a sentinel word and have the receiver swab(3) as needed if the word is reversed. That makes a lot of sense if 99% of boxes are x86.
Yeah, but once you screw up the indents in a whole file of Python source, you're not going to think that this is such a great thing. See, if you accidentally flatten out the indents of Python code, you have no clue where blocks used to begin and end. If the same thing happened in Perl, you could easily straighten things out by using the curlies as cues. (Heck, my editor will fix indents automatically for Perl.) This actually happened to me once--I accidentally sucked out all the leading spaces of every line of a Python program. The resulting mess made me re-think my infatuation with the language.
Having tried Python and having used Perl for years, I can't think of any reason why we need Python. Seems to me that anything you can do in Python you can also do in Perl. The reverse may be true, but ask yourself...does the world really need another programming language? I'm not going to be fanatic about it...use anything you think will do the job. But I'm not going to be using a language that gets upset if my indents are a off by a space, and that runs counter to my intuitive perception that white space is syntactically meaningless.
Great men are almost always bad men--Lord Acton's Corollary
>My guess is you don't like Perl becuase you never really got into it
You kidding? I love perl. I never said anything against it.
Don't read too much into a typo my friend =-)
I didn't say it would be technically difficult. It would just take awhile to prove that the other software wouldn't affect our environment. It would require alot of formal testing, documentation, discussions, and meetings. Then after that we'd end up supporting scripts in more than one language since the old code won't disappear overnight.
I aggree with you. PHP is totaly crap! Now, Im working on my own project (Designing my own templating-system/mini-language like ASP) Hey, slashdot is written in Perl right :-)
eval($i);$i="',rekcah 6lreP rehtona tsuJ'tnirp=_$";
Perhaps people who want to work for the dozens of Fortune 500 companies who have huge numbers of systems written in Perl. Or perhaps people who want to work for the large number of internet startups that use a lot of Perl code.
But, hey, if neither of those options really appeal to you then feel free to use something else. The fewer people that want to write Perl, the more I get paid for writing it.
Many businesses consider C and C++ to be "write only languages" and ban it's use in custom applications encoding business logic.
I personally know of far more businesses that consider C/C++ to be "write only" and consider Perl in the same way.
Not to mention you'd probably indent the code in any other language, python just gets rid of the extra braces.
Yeah, but once you screw up the indents in a whole file of Python source, you're not going to think that this is such a great thing. See, if you accidentally flatten out the indents of Python code, you have no clue where blocks used to begin and end.
Yeah; I've seen quite a bit of this problem from my experiments with python. Usually, it comes about when trying to exchange code via email. Lots of email software plays fast and loose with white space, not to mention the nasty problems caused by line wrapping. Getting python code safely through via email can be a real challenge. Undoing the damage for more than a few lines of code can give you a headache. It's a lot easier with languages that don't use white space syntactically; you just feed it to a "prettyprinter" and it's good again.
Of course, the real solution would be to round up all the idiots who write email software that munges the format of the text, take them out back, and work them over a bit. I've found that rational argument doesn't work with this crowd. They seem to think that it's perfectly acceptable for email software to "improve" the text by rewriting white space, and nothing you can say convinces them otherwise. Even more recalcitrant are the folks who like to convert email between plain text and HTML.
It doesn't even work to just put files in a web directory and tell people to download them. They usually do this with a browser, and lots of browsers will rewrite white space (especially tabs) and do line wrapping in with text/plain and <pre> parts of HTML files, and there's no way to prevent this.
In a few cases, the only way we've found to prevent irrecoverable damage to python code is to encrypt the text with some simple tool like uuencode, and decrypt it at the receiving end. It's a PITA for what should be a simple file copy, but it works.
With (nearly) fully-parenthesized languages like C and perl, most such damage is usually easy to undo. With python, it can be nearly impossible, because the block structure is simply gone.
Of course, this is only a problem if you're trying to share code with others. As a language for in-house, unshared code that never has to be transmitted to anyone else, python is probably fine.
Those who do study history are doomed to stand helplessly by while everyone else repeats it.
That, or the self-described programmers posting on Slashdot really are a faddish bunch of teenagers.
Hasn't everyone already heard of XML::Simple? Or are we pointing out again the reason why I stopped using perl? The fact that 99% of perl developers always reinvent the wheel rather than using CPAN.
Yes. But someone has finally figured out how to use it.
Intron: the portion of DNA which expresses nothing useful.
The PHP syntax is very similar to Perl and C.
From the PHP Tutorial
Intron: the portion of DNA which expresses nothing useful.
To install local CPAN modules, see:t /
http://sial.org/howto/perl/life-with-cpan/non-roo
Intron: the portion of DNA which expresses nothing useful.
how to invest, a novice's guide
Just have a look at the page I mentioned in my node: http://tnx.nl/php and you'll see how irremediably shitty I think PHP is.
> its 2 similar ways of doing OOP (new style vs. old style classes?) seems a little to complicated
Technically, Perl has two OOP syntaxes, too:
my $obj = new Foo();
my $obj = Foo->new();
This is my big gripe with XML::Simple. I've been using XML as protocol for dataexchange for a number of years in a number of languages and I do a great deal of Perl. I love XML::Simple when I'm parsing a very simple configuration file or a tree which is not very deep. However, it makes life so easy, that I've seen people munge in huge files with Simple, where a sax parser should have been used. I've seen people marshal out XML, when they don't understand the underlying schema - or even that such a concept exists.
A little knowledge is a dangerous thing and a (way too) powerful API is even worse. There are way too many daft Perl projects and implementations out there (in the commercial world) for this very reason. It almost makes me loath the language I love so much.
Actually, I just wasn't sure what you were getting at and wanted clarification; I wasn't questioning your statement. Clearly you've had more experience than myself with these issues, since the possibility of whitespace being non-portable hadn't crossed my mind.
Having said that, I have recently tried sending Python code via Google groups. Most people just attach files to messages, and that avoids the whole problem, but I didn't have any major problems copy/pasting my code from a web page either. The only problems I encountered were that lines were wrapped and pasted as seperate lines (this would effect most languages though). After fixing this, the code worked fine.