Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by Skeeve (Parson)
on Dec 07, 2007 at 14:47 UTC ( [id://655661]=note: print w/replies, xml ) Need Help??


in reply to Re^3: 'perl -e' and '__DATA__' What's wrong?
in thread 'perl -e' and '__DATA__' What's wrong?

That's exactly what I needed with additional __DATA__. Now replace -e with <<< or with the <<'EOT' proposed and you'll see what I meant.

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

Replies are listed 'Best First'.
Re^5: 'perl -e' and '__DATA__' What's wrong?
by duff (Parson) on Dec 07, 2007 at 14:53 UTC

    I don't get it. Are you saying that there's still a problem here? I think it's been made clear that __DATA__ isn't available from a -e script and why. If you need some extra data, just store it in a scalar or an array and use that (why bother with reading another filehandle?).

      okay then...

      Just again in slow motion...

      My script is part of an AppleScript.

      The perl script needs:

      1. STDIN or Filenames given on Commandline, read with the magic <>
      2. __DATA__

      Why _DATA__? Because I want to feed it some stuff whose content I don't know. DATA is a quite safe way for doing it, because I don't need to worry about any "dangerous" characters in it.

      Now I use a variable assignment, but i must make sure that the END marker isn't used in the data I want to store.

      So is there a problem?

      Yes, but not a big one.


      s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
      +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
        STDIN or Filenames given on Commandline, read with the magic <>

        Nope. All that's on the command line isn't read via <>, it is in @ARGV.

        Why _DATA__? Because I want to feed it some stuff whose content I don't know.

        If you use the __DATA__ token in a perl script, you must know what you put after that beforehand, which is quite the same as with a here-document in a -e script. Well, of course you could append something to a script, and invoke it later, which would be a very odd way to use the __DATA__ token.

        But you could feed your script something with a command line switch and use e.g. Getopt::Long:

        perl -MGetopt::Long -e 'use Frob; GetOptions("foo=s",$foo); frobnicate +($foo,$_) while <>' --foo="Some additional data you might pass also a +s a variable"

        --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}

        Why not a here doc with a terminator that is 99% sure not to show up in your data? like 123456789_987654321 or something.


        ___________
        Eric Hodges

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-03-29 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found