Bill Ng [bill.ng AT citigroup.com] wrote:
> Thanks,
>
> Just ordered it from Amazon.  Went the super-cheap route and ordered
> it free shipping ... should have it in a week or so.
>
>  If anyone cares, I ended up using this as my code ... it accomplished
> exactly what I was looking for:
> -------------------------------------------
> for (grep($_ !~ /$zipDir/i, @folders))
> -------------------------------------------
>
>     For those who weren't fond of that .. I'm sorry, but I did comment
> the hell out of that line =)
>
> Bill Ng
>
>
> D D Allen [dewey.allen AT us.ibm.com]
>> <snip good advice>
>>   Read Damian Conway's Perl Best Practices.  And when you feel
>>   the need to write clever code, read it again.
>> </snip>
 
Bill, as long as your goal was *less efficient and obfuscated code*,
then you succeeded. You do realize that you are making a second
copy of all of the contents of @folders less the items that do
not match your regex? In the general case, if @folders is very
large, this is hugely expensive in terms of memory compared to
iterating across the list and just not doing whatever action if
the regex does not match. In both cases you are doing the test
against each element. As far as obfuscation, yes I read that you
commented the hell out of it, but that is little comfort for
doing something so obscure and needless. Not only is it harder
to maintain, I would suggest that it is harder to extend. And
my pity if this code is handed to someone else to maintain.
 
In a subsequent post, D D Allen wrote:
> Save cleverness for the times when it could make a significant,
> measurable difference.
 
Sing it, brother!
 
--
Mike Arms


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to