in reply to Getting data *INTO* __DATA_

While not quite what you were asking, you might want to know that HTML::Template (also mentioned in a tutorial entitled HTML::Template Tutorial) does not require a file to contain the template, but can also be called initially with a reference to an array containing the template, which might be easier to manipulate. As well, HTML::Template can be used to generate text other than HTML.

As to __DATA__, I thought it was read-only (unless you start manipulating the source for later)... I could be wrong, however, and hope other monks will speak so we may both learn (and correct any errors I may have made, for which I ask forgiveness beforetimes)....

Update: Brother jeffa responded before I could submit, and in much better style. A very good read, and my hood's off to 'im.....

Update: Yes, Brother jeffa, I have indeed enjoyed the feel of braincells turning to mush upon exposure to the module you mentioned, and thus why I thought I might be incorrect....

Replies are listed 'Best First'.
(jeffa) 2Re: Getting data *INTO* __DATA_
by jeffa (Bishop) on Jul 09, 2002 at 03:16 UTC
    Have you seen Conway and Ingerson's evil Inline::Files yet? This is way cool:
    use strict; use vars qw($DATA); use Inline::Files; open DATA or die $!; chomp ($_ = <DATA>); close DATA or die $!; print "you have run this script @{[++$_]} times\n"; open DATA, ">$DATA" or die $!; print DATA $_; close DATA or die $!; __DATA__ 0

    jeffa

    you have run this script 1 times? grammar shmammar ;)
      Hmmm... You guys really got my wheels turning on this one :-) So, now, I am invisioning the use of both HTML::Template and Inline::Files. For example, in a login script using cookies as the method or remembering a previous login, I can see a template section for __LOGGEDIN__ and __LOGGEDOUT__ with totally different HTML content. Anyways, thanks for the tips, they have been quite helpful. I will post an update when I get the code written (which will be tomorow, as it is now bed time for me!)