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?? |
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. --
In Section
Seekers of Perl Wisdom
|
|