His Doojness ([info]doujoux) wrote,
@ 2007-11-15 15:57:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Current location:work
Entry tags:perl, programming

Things i am learning..
So today it was decided that i should probably learn Perl to do this thing i'm working on, since doing it all in JavaScript will break some accessibility/unobtrusivity principles. Wouldn't want that.

The problem is that i don't know Perl. At least, this morning at around 10am i didn't..

Today i've gone through Learning Perl in two and a half hours this morning and i'm onto Intermediate Perl this afternoon. I couldn't find a print version so i'm making do with an online version instead. (Eyestrain makes Dooj say ouch.) Programming Perl was extremely comprehensive but a bit hard on my brain for the sheer onslaught of stuff it covers in a short space of time; Learning Perl was nice and easy because it didn't cover anything too mind-melting, and Intermediate Perl is starting to turn up the learning curve. I found a natty little pocket reference guide for Perl too which has lots of useful lists in it at Borders for $21 too. Yay.

I've come to the preliminary conclusion that PHP makes Perl look like Japanese for its sheer compact complexity and power. There's something about Perl that's scary, something that's beautiful, something that compels me to express myself with it. It's going to be addictive stuff, i can tell.

Back to it then. Oh and if anyone's wondering, i should be crossing the halfway point of this novel during tonight's writing session.

(Edit: quoted! And now i'm going to bed.)




(Post a new comment)


[info]kjaer
2007-11-15 07:43 am UTC (link)
Just remember that the worst part about Perl is having to read somebody else's.

foreach (@fslist) {
	my $fs = "$_";
	my @shme = split('/', $fstodev{$fs});
	my $dg = $shme[4];
	my $v = $shme[5];
	open(INFO, "$vxprint -g $dg -v $v |");
	while() { $vtosd{$v} .= "$1 " if /^sd\s+(\S+)-\d+/; }
	close(INFO);
	print("$fs\t-> ($dg) ");
	my @spaz = split(" ", $vtosd{$v});
	foreach (@spaz) { print("$sdtodm{$_} "); }
	print("\n");
	}

(Reply to this) (Thread)


[info]doujoux
2007-11-15 10:29 am UTC (link)
You evil motherfucker.

(Reply to this) (Parent)


[info]doujoux
2007-11-15 10:36 am UTC (link)
Also you could probably crunch some of that code down by judicious use of map. I think.

(Reply to this) (Parent)(Thread)


[info]kjaer
2007-11-15 07:14 pm UTC (link)
I'm not sure I know map(), but I suspect it would have the result of making it even worse for somebody else to read. Half the time, if some weeks have gone by, I don't even want to look at my own Perl.

(Reply to this) (Parent)

meh
[info]saj.thecommune.net
2007-11-15 03:45 pm UTC (link)
That doesn't looks so bad to me. I'd say it is more the variable names than the syntax that makes it hard(ish) to comprehend.

(Reply to this) (Parent)

is the infinite loop intentional?
[info]livemerlyn
2007-11-15 03:55 pm UTC (link)
This is non-functional code, so I smell a troll. The while() makes an infinite loop because there's no exit from that. We also have a lack of "or die" on the open. Definitely sub-standard code at best.

(Reply to this) (Parent)(Thread)

Re: is the infinite loop intentional?
[info]kjaer
2007-11-15 07:06 pm UTC (link)
Thank you for demonstrating my point so beautifully.



ps. the infinite loop is a result of my not proofreading after pasting, and your browser eating the <INFO> which is quite definitely there.

(Reply to this) (Parent)(Thread)

Re: is the infinite loop intentional?
[info]doujoux
2007-11-15 10:34 pm UTC (link)
< &rt; is your friend. :)

(Agh now when i see HTML entities i see subs.)

(Reply to this) (Parent)(Thread)

Re: is the infinite loop intentional?
[info]doujoux
2007-11-15 10:35 pm UTC (link)
Sorry that should be &lt; &gt; - yes the R in &rt; stands for right. Yes it is early in the morning here. :)

(Reply to this) (Parent)


[info]alexchorny
2007-11-15 07:16 pm UTC (link)
You should learn:
1. modern Perl (and Perl at all, line 'my $fs = "$_";' looks very silly - it should be 'foreach my $fs (@fslist)' instead)
2. programming (at least writing comments - this code would not look good in any language)

You can write bad code in any language, in Perl it is just easier to spot (for ex. looking at your code).

(Reply to this) (Parent)(Thread)


[info]kjaer
2007-11-15 07:46 pm UTC (link)
You've offered nothing to diminish my original claim. Though, I am curious why you assume I wrote the Perl in my example.

(Reply to this) (Parent)(Thread)


[info]alexchorny
2007-11-15 09:44 pm UTC (link)
Sorry, I thought that was you code because someone periodically creates bad old Perl code and puts it somewhere in Internet claiming how bad Perl is.

It is hard to read someone's code in any language. Try writing same code in PHP (using same variable names and no comments). Would it be better? There is no 'my' in PHP. And no Perl::Critic. Also regexp would be less readable.

(Reply to this) (Parent)


[info]alexchorny
2007-11-18 10:34 pm UTC (link)
You should read this for examples of bad and unreadable code in any language: http://worsethanfailure.com/Series/CodeSOD.aspx

For ex.:
http://worsethanfailure.com/Articles/Yet-Another-Operator-Overloading-Abuse.aspx (Yet Another Operator Overloading Abuse)
http://worsethanfailure.com/Articles/My-Kind-of-copyFile.aspx (My Kind of copyFile)
http://worsethanfailure.com/Articles/Globally-Local.aspx (Globally Local)
http://worsethanfailure.com/Articles/Overflowing-Style-Sheets.aspx (Overflowing Style Sheets)

(Reply to this) (Parent)

I like that quote...
[info]livemerlyn
2007-11-15 01:36 pm UTC (link)
"There's something about Perl that's scary, something that's beautiful, something that compels me to express myself with it. It's going to be addictive stuff, i can tell."

Good stuff. Glad you are enjoying our work.

(Reply to this) (Thread)

Re: I like that quote...
[info]doujoux
2007-11-15 01:54 pm UTC (link)
Ooh! Thanks very much for writing such very effective and enjoyable works in the first place. :)

(Reply to this) (Parent)


Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…