#!/usr/bin/perl -w #use CGI::Carp('fatalsToBrowser'); #use Carp; use diagnostics; use strict; use warnings; my @pages; my @xfilenames; my @filenames; my @xtitles; my @titles; my @xheadings; my @headings; my @xstuff; my $xstuff=""; my @stuff; my @xtemplate; my $xtemplate=""; my @template; open(PAGES, "; close(PAGES); foreach $_ (@pages) { if (m/^\*{4}filename.ext\*{4}/) { push(@xfilenames, $_) } elsif (m/^\*{4}title\*{4}/) { push(@xtitles, $_) } elsif (m/^\*{4}heading\*{4}/) { push(@xheadings, $_) } else { push(@xstuff, $_) } } foreach $_ (@xfilenames) { s/^\*{4}filename.ext\*{4}//; chomp ($_); push(@filenames, $_); } foreach $_ (@xtitles) { s/^\*{4}title\*{4}//; chomp ($_); push(@titles, $_); } foreach $_ (@xheadings) { s/^\*{4}heading\*{4}//; chomp ($_); push(@headings, $_); } $xstuff = join("", @xstuff); @stuff = $xstuff =~ /\*{4}stuff\*{4}(.*?)\*{4}endstuff\*{4}/sg; open(TEMPLATE, "; close (TEMPLATE); $xtemplate = join("", @xtemplate); @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 #### perl -cw create2.pl #### C:\Perl>perl -cw create2.pl [Wed Aug 22 12:30:50 2001] (eval 1): Array found where operator expected at (eva l 1) line 1, at end of line [Wed Aug 22 12:30:50 2001] (eval 1): (Do you need to predeclare Carp::longmes s?) [Wed Aug 22 12:30:50 2001] (eval 1): Array found where operator expected at (eva l 1) line 2, at end of line [Wed Aug 22 12:30:50 2001] (eval 1): (Do you need to predeclare Carp::shortme ss?) [Wed Aug 22 12:30:50 2001] (eval 1): Array found where operator expected at (eva l 1) line 3, at end of line [Wed Aug 22 12:30:50 2001] (eval 1): (Do you need to predeclare Carp::shortme ss?) [Wed Aug 22 12:30:50 2001] (eval 1): Array found where operator expected at (eva l 1) line 4, at end of line [Wed Aug 22 12:30:50 2001] (eval 1): (Do you need to predeclare Carp::longmes s?) Undefined subroutine &Carp::longmess called at C:\PERL\lib/Carp.pm line 296.