in reply to Questions about command line script

1: 'directory=s' => \$out_dir, sets the same var to the command line switch input if available -- think of the line #7 ( not really 7 is it?) as setting a default if the command line switch is not used.

2: take a look at CGI to output something usefull to a browser.
-Waswas