use strict; use warnings; # die Prozess-IDs habe ich jetzt mal beispielhaft angelegt my $self = {}; $self->{23} = {}; $self->{64} = {}; $self->{745} = {}; my @pids = (); # 1. Beispiel @pids = keys %$self; while (@pids) { for my $pid (@pids) { @pids = grep { !/^$pid$/ } @pids unless -e "/proc/$pid"; } } # 2. Beispiel @pids = keys %$self; while (@pids) { for my $i (reverse 0..$#pids) { splice(@pids, $i, 1) unless -e "/proc/$pids[$i]"; } } # 3. Beispiel $self->{$_}->{run} = 1 for keys %$self; my $count = keys %$self; while ($count) { for my $pid (sort keys %$self) { next unless $self->{$pid}->{run}; unless (-e "/proc/$pid") { $count--; $self->{$pid}->{run} = 0; } } }