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:

unless (defined caller) { # run as command line script ... } 1;

Hugo