Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by shmem (Chancellor)
on Dec 07, 2007 at 18:27 UTC ( [id://655713]=note: print w/replies, xml ) Need Help??


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

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}

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-25 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found