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

Re: [MacPerl] Testing a form page..



At 09.02 98.01.27, Wade Williams wrote:
>Well, you certainly could have MacPerl save the STDOUT output into a file,
>which you could then open with a browser.
>
>It might also be possible to use the AppleEvent support to send the Browser
>an AppleEvent telling it to open the file automatically.

This works with Netscape ('MOSS') if it is already open.  Should work with
most browsers these days.  Writes to a temp file, opens the file in the
browser with Apple Events, then sleeps for 30 seconds before deleting the
temp file.  Edit to please.

#!perl
use CGI qw(escape);
use Mac::AppleEvents;

$text = 'hihi!';

$dir = ($ENV{TMPDIR} ? $ENV{TMPDIR} : $ENV{MACPERL});
$temp = $dir . time;
open(T,">$temp") || die "can't create temp file: $!\n";
print T $text;
close T;

($temp2 = $temp) =~ tr|:|/|;
$temp2 = escape($temp2);

$be =   AEBuildAppleEvent('WWW!','OURL',typeApplSignature,'MOSS',0,0,
                "'----':TEXT(\@)","file:///$temp2") || die "$!\n";
AESend($be, kAEWaitReply) or die $^E;

sleep(30);
unlink($temp) || die "$temp: $!";
__END__


--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==       New Book: MacPerl:  Programming for the Rest of Us       ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



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