[Israel.pm] undefined subroutines not detected at compile time

Mikhael Goikhman migo at homemail.com
Wed Mar 16 14:35:49 PST 2005

On 15 Mar 2005 15:30:52 +0200, Yossi.Itzkovich at ecitele.com wrote:
> When I use both   -w and use strict, I expect Perl to find undefined
> subroutines at compile time (assuming I don't use references to
> subroutines).
> But it doesn't.
> It finds it only at run time - like a simple shell script.
> Is there to get such checks at compile time ?

Perl is a dynamical language, fortunately or not.

This can't be checked at compile time. Here are 3 examples that
demonstrate why (all are perfectly valid perl idioms that are used
in real life, yet you suggest that they should issue a warning).

% perl -w -Mstrict
eval 'sub undefined_function { print "Hello, World\n"; }';

% perl -w -Mstrict
sub AUTOLOAD { print "Hello, World\n"; }

% perl -w -Mstrict
undefined_function() if main->can("undefined_function");


perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'

More information about the Perl mailing list