use Mac::AppleScript qw(RunAppleScript); ... sub run_script { my $script; my $msg = shift; ($script = <<" EOS") =~ s/^\s+//gm; tell application "PDFCompressor" ... # more applescript here end tell EOS RunAppleScript( $script ) or die "couldn't run applescript - $!"; } #### s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)