sub update_thing { my ($self, $x, $y, $u) = @_; if (ref $u and UNIVERSAL::isa($u, 'CODE')) { # use temp to keep the $u function from changing $_[0] ;-) my $val = $self->{cell}[$x][$y]; $u = $u->($val); } # validate $u. if ($is_valid) { $self->{cell}[$x][$y] = $u; }