in reply to Re: 'perl -e' and '__DATA__' What's wrong?
in thread 'perl -e' and '__DATA__' What's wrong?
Okay then! Here is how my AppleScript-invoked perl scripts work. I often put them inside Applescript because this way I can use Drag & Drop or some other nice stuff AppleScript offers.
Note! This example won't work, because I use -e and DATA
property some_user_changeable_config_stuff : "this data can be changed by the user of the script usually this is some kind of template, containing placeholders the perl script will fill later. Note: The user usually knows nothing about perl but a bit about AppleScript. So he will happily be using stuff like @ Quotes % etc. " on run tell me to open { choose file } end run on open some_items repeat with this_item in some_items if info for this_item is not folder then do_stuff_with(this_item) end if end repeat en open on do_stuff_with(an_item) do shell script "perl -e " & (quoted form of " use strict; use warnings; # read DATA here e.g.: my $TEMPLATE; { local $/; $TEMPLATE= <DATA>; } # and now process while (<>) { # do something with the line and the # TEMPLATE } __DATA__" & (ASCII character 10) & some_user_changeable_config_stuff) +& " " & (quoted form of POSIX path of an_item) end do_stuff_with
Of course I can check the "some_user_changeable_config_stuff" variable that a delimiter I choose isn't contained. I just wanted to avoid this, using __DATA__. So this post isn't a request for help, but just for clarification/explanation.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: 'perl -e' and '__DATA__' What's wrong?
by shmem (Chancellor) on Dec 10, 2007 at 12:41 UTC | |
by Skeeve (Parson) on Dec 11, 2007 at 09:06 UTC |