[Omaha.pm] Quick shorter code tip: for() {}
Jay Hannah
jay at jays.net
Mon May 31 12:29:00 CDT 2004
Iterating over @row is additional "overhead," but not enough that you'd
ever notice. The most efficient code on the planet is also the least
readable/maintainable, so you have to strike a balance wherever you're
comfortable.
j
On May 29, 2004, at 4:12 PM, Ted Kat. wrote:
> nice!
>
> but which has less overhead?
>
>
> --- Jay Hannah <jay at jays.net> wrote:
>>
>> This came up at work this week...
>>
>> j
>>
>>
>> BEFORE:
>>
>> while (($item_code,$enabled,$descript) = $sth->fetchrow_array)
>> {
>> $item_code =~ s/[^ -~]//g;
>> $item_code =~ s/\s+$//;
>> $enabled =~ s/[^ -~]//g;
>> $enabled =~ s/\s+$//;
>> $descript =~ s/[^ -~]//g;
>> $descript =~ s/\s+$//;
>>
>> AFTER
>>
>> my @row;
>> while (@row = $sth->fetchrow_array)
>> {
>> for (@row) {
>> s/[^ -~]//g;
>> s/\s+$//;
>> }
>> ($item_code,$enabled,$descript) = @row;
>>
>> _______________________________________________
>> Omaha-pm mailing list
>> Omaha-pm at pm.org
>> http://www.pm.org/mailman/listinfo/omaha-pm
>
More information about the Omaha-pm
mailing list