MacPerl::DoAppleScript and Perl v5.10.0

[email protected] (Alan Fry) Sun, 6 Mar 2011 14:38:02 +0000
Newsgroups perl.macperl
Message-ID <[email protected]>
I have made a small Applet containing a Perl script intended for use by =
folk not necessarily conversant with Perl. The script is inside the =
applet bundle, is called by AppleScript and works as intended.

Unfortunately the Perl script itself calls 'MacPerl::DoAppleScript' =
which causes an error if the version of Perl is 5.10.0, which is the =
case of course on 'Snow Leopard' machines. The problem can be resolved =
by setting 'Prefer-32-Bit' to 'Yes' in 'com.apple.versioner.perl.plist'. =
The question is how to achieve this, bearing  in  mind some (possibly =
most) of the users will be unused to Perl and terrified of using the =
Terminal.

I have resolved this difficulty for the moment by placing another Perl =
script in the applet bundle which reads simply

if (qx(file /usr/bin/perl) =3D~ /executable x86_64/) {
	qx(defaults write com.apple.versioner.perl Prefer-32-Bit -bool =
yes)
}

The notion behind this is that if the default version of the perl =
executable is compiled for Intel 64 bit architecture it probably is 64 =
bit perl (?) and Prefer-32-Bit should therefore be set to 'Yes'. This =
script is run before the main Perl script is launched by which time =
'com.apple.versioner.perl.plist' will have been updated.

The first question is this. Is it acceptable to change the setting of =
'com.apple.versioner.perl.plist' on someone else's machine? What if the =
owner wants to use 64 bit Perl? It is not sensible to restore the =
setting of Prefer-32-Bit to 'No' at the end of the run because the owner =
may have already set it to 'Yes' anyway.

The second question is this. Is there a better way to resolve the =
problem of how to contrive a portable Perl script incorporating a =
'MacPerl::DoAppleScript call?

Suggestions would be most welcome.

Alan Fry=