2006-04-16

Something Perl Can't Do?!

Python blows. Hard. If it's not twirling its finger in the air going "Ooh, look at me, I'm object-oriented!" then it's going around putting functions wherever the hell it feels like it instead of categorizing them, you know, sanely.

But darned if you can't finally write a one-liner to do something in Python more easily than you can in Perl:

python -c 'import time; print time.localtime(1145243792)'

Nifty. Python one, Perl a billion.

Update: Entirely by accident, I was futzing around with mod_perl today and I spotted a line in an index.pl that looked a little like "$t = localtime();" I believe my reaction was precisely as follows:

"Wait a sec. localtime() returns an array, but the $t suggests it's using a scalar context, which would—"

"..."

"Huh."

So the Perl equivalent would be:

perl -e 'print scalar(localtime(1234567890))."\n"'

Python zero, Perl a billion and one.

1 comment:

Anonymous said...

I'm sorry to post this comment on an irrelevant post, but the post I wanted to comment on is in your old blog. This is regarding COSI's Adventure in the Valley of the Unknown. I was reading your posts about it and you mentioned two computer programmer who 'almost' solved it. I think I'm one of those programmers! The reason I never solved it is that I live in Minnesota and was only there for a few days! I was going to specifically drive back to finish it and I found out that it was closed. If you would be so kind as to answer just a few questions about it, it would keep them from haunting me the rest of my days. If you're up to it, please email me nate at frozendream.com
Thanks!