Zaxo has asked for the wisdom of the Perl Monks concerning the following question:
I'm tinkering with a script which writes a fixed wrapper around perl source which is fed to it through STDIN. The wrapper code needs data which is currently stored after an __END__ tag. A problem arises if the input source uses its own DATA handle.
Following some hints in Camel3, I've tried declaring package Wrapped; before the input code to qualify the __DATA__ tag. This fail with the main::DATA handle reading from the guest code's __DATA__ tag to the end of the file. Schematically, the resulting code is structured like this:
Is it possible to use two DATA tags in the same file? I don't see a way to change namespace after the first is seen.#!/usr/bin/perl -w use strict; =pod Output: Name "Extra::DATA" used only once: possible typo at ./camtst line 23. From main Extra datum __END__ This data is for main Read on closed filehandle <DATA> at ./camtst line 23. From Extra =cut print "From main ", <DATA>; package Extra; print "From Extra", <DATA>; package main; __DATA__ Extra datum __END__ This data is for main
I'd appreciate any explanations or links about fine control of the DATA filehandle. I can obviously store namespace main's data in a heredoc or some other construct, so my question is entirely in "Search of Perl Wisdom". Thanks.
After Compline,
Zaxo
Edit Petruchio Thu Sep 20 09:11:38 UTC 2001 - Added READMORE tag.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Scope of the DATA handle
by danger (Priest) on Sep 20, 2001 at 12:24 UTC | |
|
(tye)Re: Scope of the DATA handle
by tye (Sage) on Sep 20, 2001 at 19:26 UTC |