SPUG: Bad Function Names

Asim Jalis ajalis at beryllium.cobaltgroup.com
Thu Feb 24 18:56:39 CST 2000


This question was triggered by Bob Abarbanel's excellent ESPUG
presentation last night.

Suppose I am accidentally calling a function that I have not defined.
I have no desire to use AUTOLOAD. When I run the program it will keep
running until it encounters the function call and then after not being
able to handle it it will give me a run-time error.

The question is: Can I catch this at compile-time?

This would be nice to have because otherwise I keep worrying that I
might have typos in my code waiting to explode in production. Is there
a way to catch any of this at compile-time?

Here is an example:

--------------------cut here--------------------
#!/usr/bin/perl

use strict;
  
sub bad_hello {
  bad_function ("hi there from bad_hello\n");
}

sub good_hello {
  print ("hi there from good_hello\n");
}

my $date = localtime();
if ($date =~ /sun/i) { bad_hello  (); }
else                 { good_hello (); }
--------------------cut here--------------------

This program will compile and run all week and then crash on Sunday
because bad_function is not defined. Is there a way to have it crash
at compile-time so that this bug can be caught before Sunday?

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list