in reply to Re^2: A question of perlish elegance on array loop
in thread A question of perlish elegance on array loop
use List::MoreUtils qw( natatime zip ); ## ... my $iterator = natatime 2, zip @{ $self->{ endpoints } }, @{ $self->{ +wheels } }; while( my( $wheel, $pname ) = $iterator->next( ) ) { if( $wheel->ID == $wheel_id ) { frobnicate( $pname, $wheel ); } }
Update: If only List::MoreUtils' zip behaved more like Ruby's Array#zip (which returns an Array of Arrays containing the merged items) . . . But then there wouldn't be a good Perl equivalent to auto-unwrapping the separate elements as the variables of the for loop.
</c>self.wheels.zip( self.endpoints ).each do | wheel, pname | frobnicate( wheel, pname ) end
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|