what I'm trying to do is get the start of an HTML file (until it meets ) insert the contents of form.txt, and print the rest of of the html file (from to the end).
Via debugging, I've made sure that I do indeed get the line numbers right with the first part.
The current output gives me the end of the file (after the , and after it, the form.txt content.
I just don't understand what's wrong in such small a program.
#!E:/perl/bin/perl use CGI qw(:all); use strict; print header; my ($startline, $endline); open (TEMPLATE, "index.shtml") || die "cannot find index.shtml: $!"; while (<TEMPLATE>) { $startline = $. if /^\s*<!-- MAIN -->.*$/; $endline = $., last if /^\s*<!-- ENDMAIN -->.*$/; } $startline--; $endline--; my @index=<TEMPLATE>; for (0..$startline) { print $index[$_]; } open (FORMTEMPLATE, 'form.txt') || die "cannot find form.txt: $!"; while (<FORMTEMPLATE>) { print; } for ($endline..$index[-1]) { print $index[$_]; }
In reply to Mixed-up output by Nimster
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |