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

Re: [MacPerl] Suggestion for a MacPerl Extension



Matthias Ulrich Neeracher writes on 12-JUL-1996:

!Gaspard.Gendreau@esrin.esa.it writes:
!>Is it easy, possible, difficult, impossible, already done(?) to create a 
!>MacPerl extension that would save Perl scripts as droplets, where the 
!>output would be sent *directly* to my local Web browser, not through an 
!>HTTP server?
!
!It's certainly possible but it's much easier to simply run a HTTP server on
!one's own machine.
!
!Matthias

In a similar vein I have a problem with the following web page retriever & 
optional viewer. It employs a silly little DoAppleScipt call that I would like 
to avoid (script slows down noticably there BTW):

 #!/usr/bin/perl

 my %defaults = (
 "Wilson Lab/CLEO/CESR Entry Page" =>  'http://w4.lns.cornell.edu/',
 "Yahoo!"                          =>  'http://www.yahoo.com/',
 "CUinfo-Home Page"                =>  'http://www.cornell.edu/',
 );

 my $tmp_folder = 'myMac:tmp:';
 my $browser = "myMac:Netscape Navigator Folder:Netscape Navigator 2.02";

 my $tmp_folder_slashed = join('/',split(/\:/,$tmp_folder));
 my $localhost = 'localhost';
 my @file_attributes = ("McPL", "TEXT");

 require "GUSI.ph";
 require "url_get.pl";  # <- this one works on some servers but I will switch
                        #    to maclibwww soon!

 #-----------------------------------------------------------------

 my $quit = 2;
 my $decision;

# <other parts of this script snipped>

 $decision = MacPerl::Answer(
    "Fire up a web browser now to look at\n$file\n?", "OK", "Skip", "Cancel");
 if ($decision != 2) { 
     &MacPerl::Quit($quit); 
 }
 else {
     if (!@html) {
         $file = &StandardFile::GetFile("Please select a local file:","$tmp_folder");
     }
     my $script = 

     "tell application \"$browser\"\n".
     "          GetURL \"file://$localhost/$tmp_folder_slashed/$file\"\n".
     "     activate\n".
     "end tell\n";

     &MacPerl::DoAppleScript($script);
     &MacPerl::Quit($quit);
 }

__END__

OK so here are my questions: 

1) Is there a way to call Internet Config to fire up the browser & look at 
   the localhost file? Scripting like that would seem to 
   be more Mac-platform independent (I could then copy script over to boss's 
   Mac & have it use his favorite browser e.g.)
   From what I have seen of Internet Config docs it appears to support only C 
   function calls and I have not seen any obvious XS code that will allow a 
   MacPerl call to Internet Config. Did I overlook something?

This particular application needs to run at a non-busy time each day to 
retrieve a web page URL. This requirement leads to my next question:

2) How do I write cron jobs in MacPerl? Assuming I call perl builtins like 
   localtime() & sleep() - Are there any special tricks involved in having a 
   Perl app "running in the background"? I would assume that leaving a droplet 
   (or alias) in the system folder would be necessary - does anyone have any 
   other recommendations? I would like to lower the RAM footprint as much as 
   possible.

FWIW: I am testing this on a PowerMac w/ System 7.5.3 & MacPerl 5.0.7.r1m.

Thank you.

Peter Prymmer  "clueless newbie MacOS hacker"
pvhp@lns62.lns.cornell.edu