Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Using __DATA__ from a package

by DrHyde (Prior)
on Jun 18, 2013 at 11:37 UTC ( #1039548=note: print w/ replies, xml ) Need Help??


in reply to Using __DATA__ from a package

Like this:

package Test; sub run { while(<DATA>) { print "$_\n"; } } 1; __DATA__ 1

I made two changes to your code. First, the file handle is always DATA, not PackageName::DATA. Second, I made the package return true, so that you can use it.

If you want to see some real-world examples, then check out these tests (and the modules under t/lib that they use) or Number::Phone::UK::Data


Comment on Re: Using __DATA__ from a package
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2015-07-30 05:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls