Nimster has asked for the wisdom of the Perl Monks concerning the following question:
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[$_]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mixed-up output
by chipmunk (Parson) on Jan 16, 2001 at 01:21 UTC | |
by Nimster (Sexton) on Jan 16, 2001 at 01:34 UTC | |
by chipmunk (Parson) on Jan 16, 2001 at 01:40 UTC | |
by repson (Chaplain) on Jan 16, 2001 at 09:14 UTC | |
|
(Ovid) Re: Mixed-up output
by Ovid (Cardinal) on Jan 16, 2001 at 01:25 UTC | |
|
Re: Mixed-up output
by lemming (Priest) on Jan 16, 2001 at 01:22 UTC | |
|
Re: Mixed-up output
by eg (Friar) on Jan 16, 2001 at 01:24 UTC |