in reply to Getting the DATA section of one module in the import() of another

Try using require instead of use. The DATA file handle is the same one that the Perl parser uses to read your script. By the time the use is executed, your script hasn't been completely compiled, so Perl didn't see the __DATA__ token and didn't create the connection yet. And if it did, then reading from DATA inside the used module would screw up the parsing of the rest of your script.

The require however will execute at runtime, not compiletime, and DATA will be set up.

Replies are listed 'Best First'.
Re: Re: Getting the DATA section of one module in the import() of another
by jand (Friar) on Aug 14, 2003 at 23:33 UTC
    Oops, sorry, that was incomplete.

    The require will of course not execute import(), so you will need to call it manually, which mean you should probably give it a different name.

    But either way, you won't be able to make this work from import() called by the use statement for the reasons given above.