• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Run Perl Source Text Directly from AppleScript – List AppleScript Library Handlers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Run Perl Source Text Directly from AppleScript – List AppleScript Library Handlers


  • Subject: Re: Run Perl Source Text Directly from AppleScript – List AppleScript Library Handlers
  • From: "Jacopille, David" <email@hidden>
  • Date: Wed, 15 Mar 2017 00:38:16 +0000
  • Thread-topic: Run Perl Source Text Directly from AppleScript – List AppleScript Library Handlers

Apple’s choice of Perl version tracks with the greatest module compatibility (modules that build without issue).  Perl 5.20 has the most at 25K compatible modules, but when MacOS 10.12 was released 5.18 was the leader.  5.24 only has 5,417.

 

I would also highly recommend avoiding the temptation of convenience here.  Once you use this pattern it will be more likely you will keep using it, even as complexity increases and makes it a plague upon you.

 

 

From: <applescript-users-bounces+djacopille=email@hidden> on behalf of Christopher Stone <email@hidden>
Date: Tuesday, March 14, 2017 at 6:19 PM
To: AppleScript Users <email@hidden>
Subject: Re: Run Perl Source Text Directly from AppleScript – List AppleScript Library Handlers

 

On Mar 14, 2017, at 10:30, debt <email@hidden> wrote:

It’s nice to see someone else on this list using Perl, even though 5.12 is pretty old at this point.  Is that the version that comes with Sierra?  If so, Apple should be ashamed of themselves. :(  Perl’s already up to 5.24.1, and version 5.26 is due out shortly.


 

Hey Marc,

 

#!/usr/bin/env perl -sw

    use v5.010;

 

say "Perl version $] is pretty current.";

say "";

say "Isn't it?";

 

-->

 

Perl version 5.024001 is pretty current.

 

Isn't it?

 

The stock version on Sierra is "Perl version 5.018002".

 

The use statement is simply a downward limit, and if memory serves 5.010 is the lowest version where “say” is viable.  Without such a statement you cannot employ “say”, unless you've made other arrangements.

 

http://perldoc.perl.org/functions/say.html

 

I use Macports to keep Perl (and other things) up-to-date on my system.



I would add a couple of things to your script, especially for people who aren’t well versed in Perl.  The first would be to add

 

use warnings;

 

to let you know when and where things go wrong.  Especially when embedded within AppleScript, any errors in the Perl code may be hard to spot by eye.  Also, anyone using Perl 5.10 or lower (God forbid!) will want to add

 

use strict;

 

to catch any Perl syntax errors.

 

I think you missed this:

 

/usr/bin/env perl -swf

 

Note the strict and warnings switches.  ;-)

 

Although I like the fact that Perl code can be embedded within AppleScript, I personally don’t like doing it because there’s too much escaping of the characters going on which makes it look ugly, IMHO.

 

I understand that, but it can be more convenient to have everything encapsulated in one script – particularly if you're distributing it.  (Of course a script-bundle is a good alternative in that case.)



Using BBEdit will give you syntax highlighting and it's compare documents feature is second to none (they even have a free version now).  It’s almost like a Script Debugger for other languages.  I couldn’t operate without either one now.

 

BBEdit-user since 1992.

 

--

Take Care,

Chris

 


MFS Email system made the following annotation
---------------------------------------------------------------------------------------------------------------------------------------
This email communication and any attachments may contain proprietary, confidential, or privileged information. If you are not the intended recipient, you are hereby notified that you have received this email in error and that any review, disclosure, dissemination, distribution or copying of it or its contents is prohibited. The sender does not waive confidentiality or any privilege by mistransmission. If you have received this email in error, please notify the sender immediately, delete this email, and destroy all copies and any attachments.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Run Perl Source Text Directly from AppleScript – List AppleScript Library Handlers (From: Christopher Stone <email@hidden>)
 >Re: Run Perl Source Text Directly from AppleScript – List AppleScript Library Handlers (From: debt <email@hidden>)
 >Re: Run Perl Source Text Directly from AppleScript – List AppleScript Library Handlers (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Run Perl Source Text Directly from AppleScript – List AppleScript Library Handlers
  • Next by Date: Re: notes to pdf
  • Previous by thread: Re: Run Perl Source Text Directly from AppleScript – List AppleScript Library Handlers
  • Next by thread: Calling out to Swift from AppleScript
  • Index(es):
    • Date
    • Thread