[vox-tech] reading files into a web page

Jim Angstadt vox-tech@lists.lugod.org
Sat, 2 Feb 2002 09:29:48 -0800 (PST)


--- Peter Jay Salzman <p@dirac.org> wrote:
<snip>

> <HTML>
> <HEAD><TITLE>Bulletin Board</TITLE></HEAD>
> <BODY>
> <PRE>
> `cat /www/pcgm/bulletins`
> </PRE>
> </BODY>
> </HTML>
> 
> how can i do this?  i *think* php can do this, but i
<snip>

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;
# -----

Tested on Win98.  The $mid could be indented or not.

---
Jim

__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com