Perl Through Java Eyes

mako132 on 2003-01-28T16:31:45

A Java programmer working in Perl was having a hard time debugging a for loop

for ($i=0,$t_inner=$t_pos;$i<$t_inner;$i++,$t_inner++){ $sub_date[$t_innner] = $date[$i + $t_sub];

$sub_list[$t_inner] = $date[$t_sub]; }

What struck me (besides his lack of use strict and the t_innner != t_inner typo) was how hard it is to read such code from someone who is used to manipulating arrays the hard way.


Surprising?

Matts on 2003-01-28T16:56:03

I'm not surprised the programmer was having a hard time. That's HORRID code.

Really you (or whoever is the programmer) shouldn't try and do so much in the for (...) bit. If you're going to use the C-style for loop you really should try and limit yourself to the three simple steps: define variable, test variable, increment variable. Anything beyond that is pure obfuscation.

Re:Surprising?

mako132 on 2003-01-30T22:23:56

I agree. Any more than 1 variable in the for() and you're asking for trouble...

Maybe he's memorized some favorite algorithm.