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

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

by davido (Cardinal)
on Sep 18, 2003 at 19:06 UTC ( [id://292490]=note: print w/replies, xml ) Need Help??


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

I find your second example easier to read and maintain. The first is just a lot of extra typing (quotes around everything, etc.). Of course it is a simple example, and the first example could be simplified somewhat with the qw// mechanism.

Also, remember that just as the first example assigns a list of values to an array, you could also slurp in the entire contents of the __DATA__ section with the simple my @array = <DATA>; construct. __DATA__ gives you an option: slurp, don't slurp, iterate over it several times, etc. And unlike a typical array assignment, you can manipulate the data all you want inside of the variable you read it into, and still have the original dataset there if you need to revert back to the original.

__DATA__ can also be used to roughly simulate a here document. That too can be very convenient.

Dave

"If I had my life to do over again, I'd be a plumber." -- Albert Einstein

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-03-28 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found