in reply to Test if a string is a sub name

I would use can for this. That way, whether your filters inherit functions from parents or import them, your query will work correctly.

sub My::Filters::known { } sub My::Filters::forward; for my $string (qw[known unknown forward]) { warn $string if My::Filters->can($string); }
As a bonus, you can define the package with a variable with can:

sub My::Filters::known { } sub My::Filters::forward; sub My::Other::Filters::forward; for my $package (qw[My::Filters My::Other::Filters]) { for my $func (qw[known unknown forward]) { warn $package . '::' . $func if $package->can($func); } }

Replies are listed 'Best First'.
Re^2: Test if a string is a sub name
by clscott (Friar) on Oct 06, 2022 at 12:41 UTC
    Thanks for this answer, I'll try this out as well
    --
    Clayton