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

Re: reading the __DATA__

by joe++ (Friar)
on Nov 14, 2002 at 10:34 UTC ( [id://212810]=note: print w/replies, xml ) Need Help??


in reply to reading the __DATA__

From perldoc perldata I seem to understand that __DATA__ can only occur at the end of your script:

The tokens __END__ and __DATA__ may be used to indicate the logical end of the script before the actual end of file. Any following text is ignored, but may be read via a DATA filehandle: main::DATA for __END__, or PACK- NAME::DATA (where PACKNAME is the current package) for __DATA__. The two control characters ^D and ^Z are syn- onyms for __END__ (or __DATA__ in a module). See Self- Loader for more description of __DATA__, and an example of its use. Note that you cannot read from the DATA filehan- dle in a BEGIN block: the BEGIN block is executed as soon as it is seen (during compilation), at which point the corresponding __DATA__ (or __END__) token has not yet been seen.
You could consider to eval join('', <DATA>); at runtime, which may be useful for obfuscating and to avoid compile time warnings ;-)

Update: fixed typo.

--
Cheers, Joe

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://212810]
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: (4)
As of 2024-04-24 01:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found