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

Re: [MacPerl] Command Line Arguments? (New to MacPerl)



Some time around 7/23/97 12:38 PM , John Irving wrote something about

>Hi,
>
>I'm brand new to "Mac"Perl so apologies if the answer to my question is
>obvious.
>
>I have some scripts I'm trying to port over to MacPerl (from a Unix system)
>which expect arguments to be passed via the command line. The scripts run
>fine if I manually defing @ARGV in the script but I figure that there must
>be an easier way.
>
>What's the easiest/recommended way of doing this under MacPerl?
>
>Thanks,
>
>John
>
>.....................................................................
>John Irving
>HyperConnect Online Communications
>john@hyperconnect.com
>http://www.hyperconnect.com/

One way to do it (the way I generally use) is through the MPW Shell, 
available from Apple for $99 ($49 for an update if you have an older 
version) in E-T-O #23, also bundled in the MetroWerks CodeWarrior 
distribution, and the MacPerl tool, available from CPAN (you'll see 
there's a MacPerl_appl and a MacPerl_tool, or something like that).  
Gives you a shell interface to the MacOS.

For my perl script "retrieve.pl", a line like the following works like 
you'd expect it to from a Unix command line, when entered into MPW:

perl -s retrieve.pl -match=exact -- wheel

where I'm setting the variable $match to "exact" and setting @ARGV to ( 
"wheel" ).

Another way is to have a separate file with the args, and require it in 
your script... then you only have to change the extra file and not the 
original script when the args change.

Another way:  If the arguments are filenames, save your script as a 
MacPerl droplet, and then drop the files on it.  Droplets set @ARGV to 
the files and folders dropped on them.

Yet another way:  ask for the args through <STDIN>, which is the MacPerl 
console window by default.

Hope this helps.

Dave Beverly
webmaster@thecitizennews.com -- http://www.thecitizennews.com/
Mac Manipulator
"I don't do windows!"

**
MacOS is an operating system; OS/2 is half an operating system; windoze 
is a shell; DOS is a boot partition virus... where do you want to go 
today?


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch