Whenever you have the name of a method and need a coderef, use can(), it will return undef if the object has no such method or a CODE ref otherwise.foreach my $test (@tests){ if($mask & $byte{$test}){ if (my $method = $t->can($test)) { $mask = $mask ^ $byte{$test} unless $t->$method(); } # else error handling! #if the test returned false we unset the bit } }
In reply to Re: Function refs, and trying to keep strict
by Beechbone
in thread Function refs, and trying to keep strict
by jaco
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |