If your template is large but has only a few insertion points, you can read the file into a string and use index or rindex:print <<OUT; First line! This line has a $var in it. Second line... Thanks for reading this! OUT
Beyond that, a formal templating system or module is probably best, or you can always use PHP, which is designed for embedding in pages:use strict; use warnings; my ($handle, $text, $insert); open($handle, 'template.txt'); read($handle, $text, 10000); close($handle); $insert = index($text, '<!-- INSERT -->'); print substr($text, 0, $insert); print 'My inserted data goes here!'; print substr($text, $insert);
I still like using PHP for simple things.Blah blah blah I'm inserting a variable here: <?php echo $var; ?> And again here: <?php echo $another; ?>
In reply to Re: Efficiency/Speed question... (files or formats?)
by TedPride
in thread Efficiency/Speed question... (files or formats?)
by Spidy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |