I'm not sure how many people might be interested in this, but here goes... A friend of mine recently installed MacPerl and was complaining about the lack of a CLI... I explained the way I handle user interfaces in MacPerl, but he was relatively unimpressed... then I remembered an AppleScript snippet that Chris Nandor posted a few months back and thought, "Hey, maybe I could modify that to make a semi-useful front end to MacPerl." So, since I knew basically nil about AppleScript, I dived right in! This is my first attempt at AppleScript and it turned out to be a bit more complex than I planned... What resulted is an AppleScript application I call cli4mp. What it does, in a nutshell is: (1) The user drops a perl script on the cli4mp icon. (2) cli4mp puts up a dialog prompting for the command line arguments. (3) cli4mp tells MacPerl to execute the dropped perl script passing the command line as arguments. (4) MacPerl does whatever your script tells it to with the ARGV list. However, it's not quite that simplistic. First, cli4mp passes most characters to MacPerl indiscriminately, but there are a few exceptions. (1) Space characters are the argument delimiters and are not passed unless quoted. (2) The backslash (\) is the quote character and forces the next immediate character to be inserted into an argument. (3) There are two special characters that behave sort of as directives. (a) The Option-f character (which prints as a script- like f) tells cli4mp to request a file from the user with a StandardFile dialog. If the Option-f is followed immediately by an asterisk (*), cli4mp will ask for multiple files. This is my least favorite part of the user interface, but I couldn't figure out how to manage it differently... (b) The Option-d character (which prints as a delta) tells cli4mp to request a folder from the user with a StandardFile dialog. If the Option-d is followed immediately by an asterisk (*), cli4mp will ask for multiple folders. These directives simply cause the files and folders that are selected to be inserted into the ARGV list as paths... just as if you had typed them. Because of the way I've implemented the directives, you cannot enter arguments that consist only of Option-f, Option-d, Option-f followed by an asterisk, or Option-d followed by an asterisk. However these characters and character pairs can occur in any other context... You can even select files whose names are the same as the four un-enter-able arguments by using the file/folder selection directives... Hope that wasn't too confusing. To demonstrate/test cli4mp, I used the following simple (2 line) perl script as a target: #!perl foreach my $arg (@ARGV) { print "arg: $arg\n"; } When I drag this perl script onto cli4mp, I get a dialog box prompting for the arguments. With the following input typed into the dialog box: -sw \one MyDisk:Documents:Dummy\ File \\two /abc/xyz/ \\\ I get the following output from MacPerl: arg: -sw arg: one arg: MyDisk:Documents:Dummy File arg: \two arg: /abc/xyz/ arg: \ Unfortunately, the Option-f and Option-d characters don't go through email very smoothly, so I'll ask you to use your imagination for this next example. Pretend that the 'f' is the Option-f and 'd' is the Option-d; then for the following command line: one f two d three f* hot d* cold new\ f I get the following output: arg: one arg: MyDisk:Documents:File1 arg: two arg: MyDisk:Documents:Dir1 arg: three arg: MyDisk:Documents:File2 arg: MyDisk:Documents:Dir1:File3 arg: hot arg: MyDisk:Documents:Dir2 arg: MyDisk:Documents:Dir2:Dir3 arg: MyDisk:Documents:Dir2:Dir3:Dir4 arg: cold arg: new f | +-- Where the f is really Option-f... All of the paths were selected via StandardFile dialogs. Important Note: In the loops where you can select multiple files or folders, each path item is selected individually with it's own instantiation of a StandardFile dialog. Hitting the "Cancel" button ends the loop with the previously selected path item. I know this kinda sucks, but what else can I do? What's it good for? Well, aside from letting me get my feet wet with a little AppleScripting, I admit it's uses may be limited. I think it might be useful for beginning MacPerlers who may be used to CLI interfaces to perl on other platforms. It should let them run their scripts unmodified in many cases. It could also be useful for scripts that take arguments other than file and directory paths (such as switches, regular expressions, key words, etc.). What's missing, that you would find in other CLIs? Globbing and other CLI substitutions, for one thing. I didn't find a simple way to do this in the 3 or 4 hours that I spent on this, and really... ya' gotta draw the line somewhere! Maybe in a later revision, if someone points me in the right direction. There are probably other common CLI features that are missing, and I'm just too backwards to know about 'em... Well, that's about it except for the code itself... and here's where I had a dilemma. It contains characters that aren't in the 7-bit ASCII character set and thus the code can't be posted as plain text and get mailed reliably (as I mentioned earlier). I thought about tacking it on the end of this message as a mime attachment, but then thought better of it. I don't currently have a web site that can be accessed from the real world... Also, this message was already starting to border on the ridiculously long... So, I thought I'd ask how best to distribute. Should I: (1) Send it to interested parties upon request? (2) Post it to the list as a mime attachment? (3) Send it to someone who wants to post it on a web site? (4) Some other infinitely more brilliant idea? (5) Shove it where the sun don't shine... 'cause, buddy, no one really cares? Sorry for the length of this message. cheers, jay ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org