Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Accessing the __DATA__ blocks of other packages

by archangelq (Novice)
on Aug 02, 2004 at 20:18 UTC ( [id://379412]=note: print w/replies, xml ) Need Help??


in reply to Accessing the __DATA__ blocks of other packages

I belive the solution to your problem is much simpler than implied in most of these posts. They all point out ways to accomplish what your code is trying to do, but they seem to miss what you are trying to do with your code. My solution? Read __DATA__ into a package variable, and have your subs act on it, and not try to read it inside of the sub itself. Package:
package Foo; use strict; my $data; { local $/; $data = <DATA>; } sub foo{ return $data; } __DATA__ Foo Bar Baz
Calling Code:
use Foo; print $Foo::foo;
The above prints:
Foo
Bar
Baz

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-03-29 07:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found