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. } #### foreach (@kabluther) { $x += $_->getSkookiness() if $_; # ignore undef arguments # or if ref $_; # only count ref's # or if ref $_ and $_->can('getSkookiness'); # only count objects that have this method } #### sub onTick { our $x; my $changed; # Initialize and associate $x with some external value foreach (@kabluther) { do { # these two lines must be a block - do together, or not at all. $x += $_->getSkookiness(); $changed++; } # if clause can go here I think, if needed } if ($changed) { $_->ticked() for @listeners; } return $x; }