[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] sending args to MacPerl



try:

#!perl

if( $MacPerl'Version =~ /Application$/ ) {
        # we're running from the app
        local( $cmdLine, @args );
        $cmdLine = &MacPerl'Ask( "Enter command line options:" );
        require "shellwords.pl";
        @args = &shellwords( $cmdLine );
        unshift( @ARGV, @args );
}
foreach $arg (@ARGV) {
        print "$arg\n";
}

I found this a while back in the MacPerl mail archives.  It still works 
in MacPerl 5.0.7r1m, I haven't tried with later versions.

Todd Smith


On Wed, 18 Sep 1996, Vicki Brown wrote:

> A friend sent me this question, and I'm forwarding it to the list, in 
> case anyone has any cool, simple, or elegant suggestions.
> 
> He has a perl script (to support some functions of the C preprocessor) 
> that takes arguments, e.g.:
>   -s source file path (-s is optional, but no more than one source is
>      allowed for now.)
>       -o output path (required)
>       -p progress/debugging written to standard output (optional)
>       -cb remove comments and extra white space from Chipmunk Basic files.
>     (optional)
>       -i folder in which include files may reside (optional, repeatable)
>      path ends with ":"
>   -d x=y #defines x with value y (optional, repeatable) y defaults to 1
>      if =y missing
> 
> He'd like to set this up as a standalone MacPerl (not requiring MPW or
> ToolServer) and wants suggestions as to the best way to send in the args 
> (and understand their order).
> 
> So far, ideas include:
>   - read the "real" arguments from a text file dropped onto the script 
> droplet
>   - set up files or folders with the args as their names (clunky, no 
> order)
>   - have MacPerl put up a dialog or window into which the args can be 
> typed
> 
> ...
> 
> Have I missed something really cool and wondrous?
> 
> -------------
> Vicki Brown (vlb@apple.com) - Apple Computer, Leveraged Technologies Group
> "Quality is never an accident; it is always the result of high intention,
>       sincere effort, intelligent direction, and skillful execution;
>            it represents the wise choice of many alternatives."
> 
>