perl scripting in AppleScript
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.