You can also use eval: my $eval = ""; open TEMPLATE, "<template.html"; $eval .= $_ foreach <TEMPLATE>; close TEMPLATE; my $variable = "some word"; my $result; $eval = "\"$eval\""; print eval($eval);
Or use HTML::Embperl on an HTML file like this <html><body> my variable is [+ $variable +]</body></html> Woody On Fri, Jan 10, 2003 at 11:15:14AM +1100, Hartono, Susanto wrote: > Have a look at CPAN's Text::Template. > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Friday, 10 January 2003 12:11 PM > To: [EMAIL PROTECTED] > Subject: [SLUG] Perl Passing variable to text file? > > > Hi All, > I am creating a script that will read set fields from a document, and > output them in html format from a template. > The perl script reads the data in, and assigns variables to the necessary > fields, but I am having problems outputting it. > What I would like to do is: > > example perl script (myscript.pl): > my $variable = "some word"; > > sample template html file to read in(template.html): > <html><body> my variable is $variable</body></html> > > end result: > <html><body>my variable is some word</body</html> > > is there any way to accomplish this? > > The only way I know how to do this is to print the html template at the > end of the perl file, but this is undesirable. > > I'm sorry this is hard to read, but its hard to explain. > > Regards, > > Scott > > -- > Scott Ragen > Support Manager/IT Administrator > Roadtech Systems > www.roadtechsystems.com.au > PH: +61 2 9807 3516 FAX: +61 2 9808 5294 > -- > SLUG - Sydney Linux User's Group - http://slug.org.au/ > More Info: http://lists.slug.org.au/listinfo/slug > -- > SLUG - Sydney Linux User's Group - http://slug.org.au/ > More Info: http://lists.slug.org.au/listinfo/slug -- Woody -- SLUG - Sydney Linux User's Group - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug
