#!/usr/bin/perl -w #use CGI::Carp('fatalsToBrowser'); #use Carp; #use diagnostics; use strict; #use warnings; open(PAGES, "; close(PAGES); my @filenames; my @titles; my @headings; my @xstuff; foreach (@pages) { if (m/^\*{4}filename.ext\*{4}/) { s/^\*{4}filename.ext\*{4}//; chomp $_; push(@filenames, $_); } elsif (m/^\*{4}title\*{4}/) { s/^\*{4}title\*{4}//; chomp $_; push(@titles, $_); } elsif (m/^\*{4}heading\*{4}/) { s/^\*{4}heading\*{4}//; chomp $_; push(@headings, $_); } else { push(@xstuff, $_); } } my $xstuff=""; $xstuff = join("", @xstuff); my @stuff; @stuff = $xstuff =~ /\*{4}stuff\*{4}(.*?)\*{4}endstuff\*{4}/sg; open(TEMPLATE, "; close (TEMPLATE); my $xtemplate=""; $xtemplate = join("", @xtemplate); my @template; @template = $xtemplate =~ /^(.*?)\*{4}filename.ext\*{4}/sg; push (@template, $xtemplate =~ /\*{4}filename.ext\*{4}(.*?)\*{4}title\*{4}/sg); push (@template, $xtemplate =~ /\*{4}title\*{4}(.*?)\*{4}headings\*{4}/sg); push (@template, $xtemplate =~ /\*{4}headings\*{4}(.*?)/sg); for (my $i=0; $i < (@filenames); $i++) { open(FILE, ">@filenames[$i]") || die $!; print FILE qq($temlate[0] $title[$i] $template[1] $heading[$i] $template[2] $stuff[$i] $template[3]); close(FILE); } print "Content-type:text/html\n\n"; print < create EndHTML foreach (@filenames) { print "

Name:$_

"; } print "
"; foreach (@titles) { print "

Titles:$_

"; } print "
"; foreach (@headings) { print "

Headings:$_

"; } print "
"; foreach (@stuff) { print "

stuff:$_

"; } print < EndHTML