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

Re:[MacPerl] Newbie question ....



At 6:45 PM 10/22/96, Drew Linsalata wrote:
> ...how do I get my
> script to take its input from the file we drop on it?

The files or folders dropped on the MacPerl droplet automatically go into
@ARGV. You can then go through each one and selectively open them. For
example:


foreach $thing (@ARGV) {
  ($creator,$type)=&MacPerl'GetFileInfo("$thing");
  if ($type eq "TEXT") {
    print "$thing is a text file. Opening it now.\n";
    open (TEXTFILE," $thing");
    while (<TEXTFILE>) {
       # split up each line into an array of items which were separated by tabs
       @fields=split(/\t/,$_);
       # do something creative with @fields
    }
    close TEXTFILE;
  }
}

Make sure you save the script as a droplet.

-Dave