[Koha-devel] koha code cleaning bug?

Chris Nighswonger cnighswonger at foundations.edu
Tue Sep 30 13:55:41 CEST 2008


On Mon, Sep 29, 2008 at 12:43 PM, Joe Atzberger <ohiocore at gmail.com> wrote:
>
>
> On Mon, Sep 29, 2008 at 11:03 AM, Galen Charlton
> <galen.charlton at liblime.com> wrote:
>>
>> Hi,
>>
>> On Mon, Sep 29, 2008 at 9:42 AM, Marc Chantreux
>> <marc.chantreux at biblibre.com> wrote:
>> > do you think that:
>> >
>> > for my $var ( list_generator ) {
>> >    $var =~ /useless/;
>> >    $var =~ s/old/new/;
>> >    next unless -d $var;
>> >    mkdir $_;
>> > }
>> >
>> > is more readable than:
>> >
>> > for ( list_generator ) {
>> >    /useless/;
>> >    s/old/new/;
>> >    next unless -d;
>> >    mkdir $_;
>> > }
>>
>> I do. :)
>
> I don't.  I actually prefer the latter.  And if you construct the example
> more conventionally, it should be obvious what the topic is without any
> explanatory comment.
>
> foreach (@directories) {
> ...
> }

This is a nice compromise for non-nested loops.

But as far as that goes, its a tossup. However, avoiding unnecessary
obfuscation should be the guiding rule, IMHO. So I think when it is
clear, use punctuation strings and when it is not, don't.

I only wonder if there is any performance gain by using $_ vs assigning a $var?

Regards,
Chris



More information about the Koha-devel mailing list