@EXPORT means that stuff will be force fed to the caller (where you say use Apples)- means the calling script/package will be injected, its namespace raped and pillaged, with whatever you have in @EXPORT.
You want @EXPORT_OK, which lists what your caller *may* at its choosing, take bites of- import into its namespace.
require is runtime, use is compile time.
If in the middle of your code (say, line 50) you have require Apples; and Apples is not present or found on the system, you don't get an error until you get to line 50.
In addition to that, you don't load Apples until line 50. So, if you have an intense operation involving multiple modules and code, you may want to (for performance sake) load modules as they are needed (with require). This is not usually necessary. Personally I've been doing it a lot.
If in line 50 we had use Cwd; instead of require Cwd, then as soon as you run your program, we check for and load Cwd, at compile time. If you don't have it your program fails, immediately. Also, every use statement in your code goes through the same thing. This is useful to check for errors or missing deps before your program runs.
This stuff is basic-ish- but there are odd abstract snags and peculiarities- have you tried reading perdoc and cpan? It might be weird at first but it helps a lot.
In reply to Re: uses of Exporter, @EXPORT
by leocharre
in thread uses of Exporter, @EXPORT
by l.frankline
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |