in reply to Re: A question of perlish elegance on array loop
in thread A question of perlish elegance on array loop
sub endpoint_dead { my ($kernel, $heap, $wheel_id) = @_[KERNEL, HEAP, ARG0]; $kernel->post('MAIN-Logger', 'alert', "Endpoint managed by wheel $ +wheel_id died\n"); my $self = $heap->{self}; # find the wheel and restart endpoint foreach(0..$#{@{$self->{endpoints}}}){ my $wheel = $self->{wheels}->[$_]; my $pname = $self->{endpoints}->[$_]; if($wheel->ID == $wheel_id){ [...]
Or even more elegant than the for construct in the original question.# find the wheel and restart endpoint my $i = 0; foreach(@{$self->{endpoints}){ my $pname = $_; my $wheel = $self->{wheels}->[$i]; [...] $i++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: A question of perlish elegance on array loop
by Fletch (Bishop) on Nov 30, 2007 at 00:49 UTC | |
|
Re^3: A question of perlish elegance on array loop
by friedo (Prior) on Nov 30, 2007 at 00:40 UTC | |
|
Re^3: A question of perlish elegance on array loop
by aquarium (Curate) on Nov 30, 2007 at 02:00 UTC |