The next question is why it is not preferred. Several reasons:
- If a script uses multiple modules that autoexport lots of stuff, it quickly gets hard to figure out where any given function came from. Give users the option to enforce sanity by documenting what came from where.
- When independent modules put things into package main, it becomes very easy for private functions in one to conflict with private functions in another. Tracking down and resolving these conflicts grows more complex rapidly as the number of functions and files grows. (With 5 files you only have 1/4 the number of possible lines of conflict as you do with 10.) Putting each file in its own package reduces the damage from such internal conflicts.
- It is preferred that you not export every function. Good modularity in procedural code is to have each module have a simple API. A ton of exported functions is a very complex API.
Yes, you can do what you ask for. Perl gives you enough rope to hang yourself. But that doesn't mean that you should do it...
UPDATE: I used the word "recommended" where I really meant "preferred".