You could use eval EXPR, but passing a sub reference is safer, clearer and easier.
my $condition = sub { !-d $_[0] }; my $result = checkForDirectory($condition); sub checkForDirectory { my $condition = shift; ... if ($condition->($someDir)) { doSomethingElse(); } }
In reply to Re: Pass conditions to a subroutine
by ikegami
in thread Pass conditions to a subroutine
by PerlRob
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |