I posted this so that people can see what Perl applications actually look like these days. A lot of folks here haven't looked at Perl since 1995, and assume it's the same now as it was then. It's not :)
It is impressively more readable than some legacy Perl code I've had the misfortune of working with. That being said, just on a quick once-over for aesthetics I'm not left thinking "Ahh, modern Perl sure looks less painful than modern Ruby or modern Python."
I don't even write Python, but looking at it has never given me a seizure. Not that your code is seizure-inducing, mind you.
I've had some problems diving into Perl land, and I'd appreciate your thoughts. While it's obviously very possible to have clean and elegant code in any language (corollary: you can write cobol in any language), I've found that when I'm stuck and I go to Google for a hint, the piece of code I'll end up with will never follow any common style guidelines -- it's always different.
In contrast, Python seems to have more style conventions designed into the syntax and the language, and when I last did much with ruby (pre-rails) it seemed pretty intuitive overall (something about "principle of least surprise").
I don't have much skin in this game: I'm a sysadmin by trade and tend to stick to the traditional Unix tools, but I would like any suggestions you have for people who want to develop good taste in Perl syntax and program design.
I would like any suggestions you have for people who want to develop good taste in Perl syntax and program design.
I've thought about writing a non-insane style guide for Perl, but the more I think about it, the less important I think style is. I can read code regardless of the style, and honestly, a style that's different from mine doesn't slow me down at all.
It's a shame that people think PBP is "the Perl style guide", though, and I'd really like to correct that misconception... but it just doesn't matter at all.
No, not the sigils, but the level of over-engineering just to get going. Look at that first code example. Unintelligible or what. If this is where Perl's going, I'm glad I ditched it several years ago.
No.. why? Was that a joke? It's a poor show of one's convictions when one has to resort to playground tactics to try and make someone look silly rather than discuss something like an adult :(
Agreed, it is not the same, but I'm saying if I needed to resolve a shortened URL, I would do it myself instead of sending an HTTP request to you so that you can send an HTTP request on my behalf. At any rate, using your service would be slower because of the extra roundtrip, and more unreliable.
However, I appreciate your post for enlightening what modern Perl looks like. After a quick skim I thought I was looking at Rails.
One advantage of my "service" is that if the URL redirector goes down, you still have a chance at getting my cached copy.
The point of the article is not the service, but rather what the code looks like. Returning "Hello world" is almost as instructive, but not quite, so I chose a dumb example instead.