From: Peter Hickman Date: 2002-08-27T17:18:26+09:00 Subject: Re: Converting Perl scripts to Ruby? Tim Hammerquist wrote: >I'm not sure what you're gripe is here. Ruby's iterators also >use an extra variable. That's what appears between the ||'s. > >But for the sake of accurate equivalents, let's use _idiomatic_ >Perl. You've neglected to show this much cleaner version: > > foreach my $x (@accounts) { > $x->interest = $x->holding * $interest_rate; > } > >And using implicit use of $_: > > foreach (@accounts) { > $_->interest = $_->holding * $interest_rate; > } > For some programmers (myself included) the creation of a surrogate variable, the implicit $_ or the explicit $x, is a bad thing. It uses up valuable name real estate and in all honesty only exists because the language mandates you should have one. Idiomatic Perl is not the same as idiomatic Ruby. In the Ruby the |account| local variable is not a surrogate to dereference the account in question, it is the account. I agree your Perl code is cleaner but I was just hacking something up to show a point. Unfortunately there's more Perl code like mine in the world than there is like yours, mores the pity. > >Very true. I can't say this enough: Perl's OO model is a >gigantic ball of bovine excrement, even if it does do some nifty >tricks. If the rest of Perl weren't so useful, I'd have nothing >to do with it. > Perl OO reminds me of C++ written by seasoned C programmers. (mutters something about old dogs and new tricks)