[San-Diego-pm] Detect invocation method?

Reuben Settergren ruberad at gmail.com
Fri Dec 10 11:08:43 PST 2010

Hi Mongers,

I'm writing some simple scripts for some very command-line-phobic users; or
let's just say they would prefer a mousy solution over a typey solution.

I've already made the script do useful things with no arguments, so they can
keep the script on their desktop, paste it into any directory and
double-click it, and then the script will discover input files in that
directory with glob() and do its thing.

I've also come up with some clever (but probably not original) techniques
like checking the special variable $0 (that's a zero) for _test or _verbose,
so I can tell if they changed the filename, and then I can behave as if they
had run from the command line with the equivalent switches, and hold up the
cmd window at the end with "Press <enter> to close this window".

But I'm looking for ways to make it even more idiot-proof.

Does anybody know of a way that I can tell whether my script was invoked
from the command-line or by double-clicking? (other than checking $0 and
trusting that the user will never double-click the script meant for
command-line invocation?)

Is there any way to package up a perl script (or .bat?) such that input
file(s) can be selected with the mouse, and dragged into the icon for the
script, so that the script would then run with the (full?) paths to the
selected files as its command-line arguments? (This is a mac paradigm,
right? I've never seen this on windoze or unix)

Also open to other clever ideas you may have to offer...


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/san-diego-pm/attachments/20101210/d3909a8b/attachment.html>

More information about the San-Diego-pm mailing list