[vox-tech] reading files into a web page

Peter Jay Salzman vox-tech@lists.lugod.org
Sat, 2 Feb 2002 23:44:43 -0800


jim, just out of curiosity, in my hypothetical webpage:

   <HTML>
   <HEAD><TITLE>Bulletin Board</TITLE></HEAD>
   <BODY>
   <PRE>
   `cat /www/pcgm/bulletins`
   </PRE>
   </BODY>
   </HTML>

where would the perl code go?  (i am a total newbie in dynamic webpage
content).   sorry if this question is painful, but i honestly don't
know.  :)

pete

> Hi Pete,
> 
> Don't know PHP but Perl could do it:
> 
> # -----
> #!/perl/bin/perl.exe -w
> use strict;
> use File::Slurp;
> 
> my $file = 'template.txt';
> my $mid = '
>    <PRE>
>    `cat /www/pcgm/bulletins`
>    </PRE>
> ';
> 
> my $template = read_file( $file );
> $template =~ s/<body>.*<\/body>/<body>$mid<\/body>/is;
> 
> print $template;