in reply to Reading in Text File and skipping lines

The <FILEHANDLE> construct is actually a shortcut for reading in a line from the filehandle and storing it in $_. By effectively calling <FILEHANDLE> two times in your block you are only appending every other line. Try this:
while( <TEMPLATE> ) { $outputpage .= $_; }

Replies are listed 'Best First'.
Re: Re: Reading in Text File and skipping lines
by shemp (Deacon) on Nov 07, 2002 at 22:33 UTC
    This is a great example of why i discourage the use of $_ and other implicit variables. It perpetuates misunderstanding of what is really going on. Do others feel that this shorthand leads to confusion, or am i too anal?
    I like to go one step further in reading files:
    while( my $line = <TEMPLATE> ) { $outputpage .= $line; }
    or even
    my @lines = <TEMPLATE>; foreach my $line (@lines) { $outputpage .= $line; }
      Do others feel that this shorthand leads to confusion, or ...

      It's only confusing until you get it. =) After that, it leads to simplification and reduced clutter in scripts.