sub some_interesting_function { ... here we do the real work ... } sub main { ... This is called if run as a script ... ... blah, blah, blah, setup ... some_interesting_function(various arguments); } # Detect if we're being called as a CLI script or module. If CLI # script, execute main. main(@ARGS) unless caller();