Compile-time syntax errors#

Errors the parser raises before the program runs. A compile-time error stops the whole program: nothing executes, because the source could not be turned into runnable ops. Unlike runtime dies, these are not trappable with eval BLOCK - but a string eval of source that fails to compile reports them through $@:

my $code = '1 +';
eval $code;
warn "compile failed: $@" if $@;

Subroutine resolution at compile time#

`Undefined subroutine &%s`#

(F) The parser resolved a call to a named subroutine that does not exist at compile time. This is the compile-time companion to the runtime Undefined subroutine &%s called error: the difference is when the missing sub is noticed. Make sure the defining module is used, and that the name is spelled correctly and fully qualified where the package matters.

See also#

  • General fatal errors - the runtime form of the undefined-subroutine error.

  • Subroutines - declaration, prototypes, and the rules that decide when a call resolves.

  • use - pulls in the module that defines the subroutine, at compile time.