sub data_generator { return maybe_unknown(@real_data); # attach maybe_unknown flag } sub data_processor { for my $data (@_) { if ($data =~ /foo/) { # in development this line croaks # because $data may be unknown. # Note that it will croak even when $data # is not actually 'unknown'! ... } unless (is_unknown($data)) { # clears the maybe_unknown flag if ($data =~ /foo/) { # does not croak because the maybe_unknown # flag has already been removed from $data ... } } } sub main { data_processor(data_generator); }