in reply to Re: Possible to catch undefined sub at "compile" time?
in thread Possible to catch undefined sub at "compile" time?

Andreas, thanks, but this is catching the problem at runtime. Ideally what I would like is a warning/error when referencing a sub which is not already defined. I'm sure this isn't possible in the general case, but perhaps it is possible for code similar to my simple example?
--Ben
  • Comment on Re^2: Possible to catch undefined sub at "compile" time?

Replies are listed 'Best First'.
Re^3: Possible to catch undefined sub at "compile" time?
by jhourcle (Prior) on Oct 10, 2007 at 12:05 UTC

    The problem is, it may require running the script to determine if a function really isn't defined. You may have two scripts that declare functions into the same namespace, use AUTOLOAD, or generate functions within the script (possibly with input from an external source)

    foreach my $function (<DATA>) { no strict refs; chomp $function; *$function = sub { print "$function : @_\n"; }; } mink(12); go('somewhere'); monk(8); __DATA__ mink go
Re^3: Possible to catch undefined sub at "compile" time?
by andreas1234567 (Vicar) on Oct 10, 2007 at 11:55 UTC