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

Re: [MacPerl] use of @ARGV in Unix/Mac



> Why don't you write a simple script that emulates a command-line.
> Something like:
<snip>
>     $RunThis = "";
>     open(SCRIPT, "<$Script");   while(<SCRIPT>) { $RunThis .= $_ };
> 
>     eval $RunThis;           ## Run it

Just one problem: this won't work with droplets, which store their code
in the resource fork. Here's a subroutine which will fix that:

use Mac::Resources;
use Mac::Memory;

sub RunScript ($) {
  my $s = shift;
  if (defined $s) {
    if (MacPerl::GetFileInfo($s) eq "TEXT") {
      do $s;
    } else {
      defined(my $rs = OpenResFile $s)
        or die "Could not open droplet";
      defined(my $dh = Get1NamedResource "TEXT", "!")
        or die "Application is not a droplet";
      $EvalPath = $s;
      eval $dh->get;
      $EvalPath = "";
      die $@ if $@;
      CloseResFile($rs);
    }
  }   
}

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.

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