Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: 'perl -e' and '__DATA__' What's wrong?

by Skeeve (Vicar)
on Dec 10, 2007 at 11:37 UTC ( #656094=note: print w/ replies, xml ) Need Help??


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.


s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e


Comment on Re^2: 'perl -e' and '__DATA__' What's wrong?
Select or Download Code
Re^3: 'perl -e' and '__DATA__' What's wrong?
by shmem (Canon) on Dec 10, 2007 at 12:41 UTC
    Then I'd rewrite that as follows
    on do_stuff_with(an_item) do shell script "perl -e " & (quoted form of " use strict; use warnings; use Getopt::Long; # get Template from the command line my $TEMPLATE; GetOptions("template=%s",\$TEMPLATE); # and now process while (<>) { # do something with the line and the # TEMPLATE } ") & " " & (quoted form of "--template=" & some_user_changeable_config +_stuff) & " " & (quoted form of POSIX path of an_item) end do_stuff_with

    yay, first AppleScript hacking I did did do! ;-)

    Dunno whether I got everything right, but the idea is to stuff into a command line argument that which you wanted to stuff into the DATA section.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

      You didn't get everything right I fear, but I got the idea!

      Thank you! YOU ARE MY HERO!

      Too bad I just can give 1 ++...


      s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
      +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://656094]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-07-11 03:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (217 votes), past polls