Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Template file include in code?

by DreamT (Pilgrim)
on Oct 22, 2009 at 14:48 UTC ( [id://802758]=perlquestion: print w/replies, xml ) Need Help??

DreamT has asked for the wisdom of the Perl Monks concerning the following question:

So, I have 2 files: file.pl, that is a script that posts an xml call to a certain service, and file.dat, that is a template file for the xml posting.

Everything works just fine, but due to distribution reasons i'd like to include the template in the script. The obvious solution is to include the template in a variable, but I want to do it in a more easy managed way.
Any suggestions?

Replies are listed 'Best First'.
Re: Template file include in code?
by moritz (Cardinal) on Oct 22, 2009 at 14:57 UTC
    See the description of the DATA file handle in perldata.
    Perl 6 - links to (nearly) everything that is Perl 6.
      Ok! Is it availabel for Perl 5 as well?
        The perl6 bit is just his sig.
Re: Template file include in code?
by tswall (Monk) on Oct 22, 2009 at 17:27 UTC
    May I offer an example, my esteemed monks?

    use strict; use warnings; print <DATA>; __DATA__ <myXML> <myData>This is some data.</myData> </myXML>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-26 01:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found