Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Static Data ("__DATA__" vs. "our")

by tcf22 (Priest)
on Sep 18, 2003 at 19:08 UTC ( [id://292491]=note: print w/replies, xml ) Need Help??


in reply to Static Data ("__DATA__" vs. "our")

I usually use DATA for like small templates for my script output. This is really the only time I use it in the real world. I think is just a matter of preference, and not performance, but only Benchmark can tell the truth about that.

I think the reason you see it a lot here, is that it is very easy to show what is going on when file processing questions are asked, because you can read it in like a Filehandle, but it is in the script, so you can post with the code.

- Tom

Replies are listed 'Best First'.
Re: Re: Static Data ("__DATA__" vs. "our")
by shenme (Priest) on Sep 18, 2003 at 19:24 UTC
    I think the reason you see it a lot here, is that it is very easy to show what is going on when file processing questions are asked, ....
    Yes.   Oftentimes we are trying to help posters who are having quite enough difficulty grasping basic Perl syntax, without asking them to understand why setting up a data structure and manipulating in a particular way is 'like' reading a file.   Using __DATA__ is the _gentlest_ way of helping them to understand the point of the blessed reply, without looking like we are cursing at them in perLatin.
Re: Re: Static Data ("__DATA__" vs. "our")
by wolis (Scribe) on Sep 19, 2003 at 03:13 UTC
    I'm new to this __DATA__ concept.. is ther an __END__ to define the end of the data or does the end of file define the end of data?

    This would mean that only one file can be included in one file of code?

    or can you use anything like:

    my @lines = <PEANUT>; __PEANUT__ Bing Bong Bang
    ___ /\__\ "What is the world coming to?" \/__/ www.wolispace.com
      From perldata:
        __END__ and __DATA__ may be used to indicate the logical
        end of the script before the actual end of file. Any
        fol­lowing text is ignored ...
      
        For compatibility with older scripts written before
        __DATA__ was introduced, __END__ behaves like __DATA__
        in the toplevel script (but not in files loaded with
        "require" or "do")
      
      There is no token to define the end of data, but there is Inline::Files. :)
      use Inline::Files; print while <PEANUT>; print while <BUTTER>; __PEANUT__ Bing Bong Bang __BUTTER__ Foo Bar Baz

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)
      
        Coolamundos :-)
        ___ /\__\ "What is the world coming to?" \/__/ www.wolispace.com

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-25 06:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found