#Require the file with the function definitions. #Use eval to catch errors. eval { require "definitions.pl"; }; #__PACKAGE__ is a token that gets replaced with the #name of the current package. You must not quote it. #Why? Because Perl said so. my $package = __PACKAGE__; #Add a 'can' test to each function call... #This is the shortest. It uses object-oriented #calling syntax: top() if $package->can('top'); #If you don't like dangling if's, try this: if ($package->can('middle')) { middle(); } #This short-cuts the object-oriented calling syntax, #and uses the relatively obscure UNIVERSAL package #directly. #IMO it's really messy, but it's technically the fastest. end() if UNIVERSAL::can($package,'end');