• 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
perl scripting in AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

perl scripting in AppleScript


  • Subject: perl scripting in AppleScript
  • From: John Fowler <email@hidden>
  • Date: Sun, 21 Dec 2003 21:28:22 -0600

Dear scripters,

In the bbedit shell worksheet, the following construct yields the
desired dump of file contents:

perl -n -e 'open
(INFILE,"/Users/johnfowler/Desktop/myactivity.txt")||die
("here");$thisvar=<INFILE>;print $thisvar;'

But the following AppleScript yields a null string:

do shell script "perl -n -e 'open
(INFILE,\"/Users/johnfowler/Desktop/myactivity.txt\")||die
(\"here\");$thisvar=<INFILE>;print $thisvar;'"

But if I remove -n from the shell script I am golden again:

do shell script "perl -e 'open
(INFILE,\"/Users/johnfowler/Desktop/myactivity.txt\")||die
(\"here\");$thisvar=<INFILE>;print $thisvar;'"

>>file dump as desired.

Realizing that

>The `-n' causes Perl to assume the following loop around your script
which
>makes it iterate over filename arguments
>
>LINE:
>While (<>) {
> ... # this bit being your script
>}

As Phil was kind enough to teach me a couple of exchanges ago(and which
I eventually found in one of perl's many manpages), why does it work in
the worksheet context (though not necessary, since omitting -n doesn't
change the output) and not in the applescript context? Is there a
knowable rule for when -n should be used in do shell script?

Thanks

John Fowler
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: perl scripting in AppleScript
      • From: John Fowler <email@hidden>
  • Prev by Date: Re: Panther bug: "Volumes" folder not updating
  • Next by Date: Re: Show/Hide invisibles
  • Previous by thread: Re: Panther bug: "Volumes" folder not updating
  • Next by thread: Re: perl scripting in AppleScript
  • Index(es):
    • Date
    • Thread