Subject: | Document that compile needs to be called from within the subroutine |
If compile is called outside the subroutine, any errors are reported from the place the coderef is called, not the caller's location.
E.g. this won't be as expected:
my $check = compile( Int );
sub foo {
my ($int) = $check->(@_);
}
But this will do the right thing:
my $check;
sub foo {
$check ||= compile( Int );
my ($int) = $check->(@_);
}