foreach (@kabluther) { #... } if (@kabluther) { # the "..." above was executed # i.e., your $x was modified $_->change_in_x() for @listeners; # sounds like this is something like what you want to do. }