I like to require any other files at the beginning of the main script then just call the routines in them as needed. This may or may not be the best way, but it works pretty well for me. By the way, if I remember correctly, I believe the file you're calling does not necessarily need the standard
perl script header, does not have to end in "pl" or "cgi", and does not need executable permissions.
(main_file.pl)
#!/usr/bin/
perl
require "other_file.pl";
&do_something;
&do_something_else;
exit;
(other_file.pl)
sub do_something{
print "Content-type: text/html\n\n";
print "ok";
}
sub do_something_else{
print "Content-type: text/html\n\n";
print "ok again";
}
1; # return true
I didn't test that script, but I know it's real close to what I do.