You just want to split them into multiple .pm files and then include those into your application pm with the use command.
If it's a small application it's okay to drop them all in the same directory and then perl will find them without you fiddling with the @INC paths
# main pm file
use ajax;
hello();
#ajax.pm
sub hello
{
print "hello\n";
}
Notice that there is no package declaration in the ajax.pm file. This means that all of the functions will be imported directly into your namespace with no fuss.
All this will work, but may become a problem in the future if the application grows too large. It might be wise to separate things into their own namespaces, and use Exporter to only expose the necessities. You'll have to judge for yourself on that one.
|