Looking at all of this OSA stuff, I wonder if there might be another way. Here is a thought of another way to do this: use Mac::Glue; use Mac::MoreFiles; $finder = Mac::Glue->new('Finder'); $finder->select( 'startup disk' ); $finder->open('selection', { using => qq[alias "$Application{'R*ch'}"] }); $finder->glue_finish; This would get converted to the text: tell application "Finder" select startup disk open selection using alias "HD:BBEdit 5.0:BBEdit 5.0" end tell And it would be compiled down into an OSA script. Then it could be executed: $finder->glue_execute; Of course, there is a big downside here: it takes a lot longer to compile an OSA script than it does to execute an Apple Event. #!perl -w use Benchmark; use Mac::OSA::Simple; use Mac::AppleEvents::Simple; use strict; use vars qw($as $osa $as_c $osa_c); $Mac::AppleEvents::Simple::SWITCH = 0; # two ways to do same thing $as = [qw[misc slct MACS], q"'----':obj {form:prop, want:type(prop), seld:type(sdsk), from:'null'()}"]; $osa = <<EOS; tell application "Finder" select startup disk end tell EOS # compile it first $as_c = build_event(@$as); $osa_c = compile_applescript($osa); timethese(100, { AppleEvents => 'do_event(@$as)', OSA => 'applescript($osa)', AppleEvents_C => '$as_c->send_event', # note, there is a bug in # current Mac::AppleEvents::Simple # so this will not work for you :) OSA_C => '$osa_c->execute' }); __END__ Benchmark: timing 100 iterations of AppleEvents, AppleEvents_C, OSA, OSA_C... AppleEvents: 5 secs ( 5.10 usr 0.00 sys = 5.10 cpu) AppleEvents_C: 5 secs ( 4.80 usr 0.00 sys = 4.80 cpu) OSA: 8 secs ( 8.33 usr 0.00 sys = 8.33 cpu) OSA_C: 6 secs ( 5.43 usr 0.00 sys = 5.43 cpu) Unfortnately, precompiling the OSA script and storing it (in the file resource fork, for instance) is not a good option, because often there will be perl expressions passed to the scripts which would need to be evaluated at run time. So, comments or thoughts? -- Chris Nandor mailto:pudge@pobox.com http://pudge.net/ %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6']) ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org