in reply to java/c has main - perl has ?
When a module is used or required, the user (or requirer) is set up as a caller, accessible using caller. You can take advantage of that like so:
Hugounless (defined caller) { # run as command line script ... } 1;
|
|---|