Showing posts with label Perl. Show all posts
Showing posts with label Perl. Show all posts

15 April, 2009

PhizzleDizzle Is Right

Python is a lot more intuitive than Perl. Perl is all twisted up in contractions and brackets and weird contractions whereas Python has just a few punctuation sets and very clear functional parsing. I spent 3h on a Python tutorial and have managed to write scripts that I haven't been able to write even after a couple months of casually studying Perl. The only non-intuitive thing I've found in Perl so far has been trying to link an operation inside of a "while" loop to a condition set outside the loop. With this, it took me about 40min to figure out what was wrong with my script to ask for numbers one at a time until the sum was 100 or greater, because the loop kept quitting after 2 numbers. I think I've got it now.

Bonus: Python can do more than just parse text files. This has been one of my frustrations with Perl so far, I could write a little script to change all the "ae" in a text document to "รค", but when it came to actual utility it was kind of limited. I have no doubt that Perl is useful for large-scale Internet applications, I now think that Python might be a more useful skill to develop. I'm not going to give up completely on Perl, but for the moment Python suits my curiosities much better. There's even a serial.py module that let's Python talk to micro-controllers!

So yes, Phizzle Dizzle was right. Python seems to be just as powerful, more intuitive, and offer a much shallower and less painful learning curve. Also, the IDLE Python GUI is quite nice.

19 January, 2009

Aside: Perl

I am trying to learn how to code in Perl. I am doing this because I find computational biology and mathematical modeling of biology to be intensely interesting. However, writing meaningful programs is currently a bit beyond my abilities. So, I submitted a variant of this as a joke to Thinkgeek. I thought I might post this for all of your enjoyments/amusements.
#!/usr/bin/perl

print "Who is awesomer (you/me)? ";
chomp($base = );

if ($base eq you) {print "Correct, you can has cookie.\n"};
if ($base eq me) {print "Fail.\n"};
If you should wish to actually run this program (for whatever bizarre reason), then:
1) Copy-paste into Notepad or a simple text editor (not MS Word).
2) Save somewhere you'll remember it at.
3) Access the folder you stashed it in from your command line using the \cd function.
4) Type "perl filename" (filename = whatever you named it) and it will run (this'll work natively in a Unix system [Mac]{I think}, might be more difficult in a Windows environment, where you'll need a Perl module installed).
5) If you want to alter it to help boost your self-confidence or momentary feelings of awesomeness, then you can alter the pieces following in bold.
#!/usr/bin/perl

print "Who is awesomer (you/me)? ";
chomp($base = );

if ($base eq you) {print "Correct, you can has cookie.\n"};
if ($base eq me) {print "Fail.\n"};
For it to work, red has to match red and blue has to match blue, letter for letter. And the space after the question mark is important, so don't delete it.

I think this qualifies me as a script kiddie. Which I don't think is too bad, considering that I'm trained as a molecular biologist and all.