simple: The trick is to defer printing till next time in the loop.
open(OUT,">$myoutfile"

or die "cannot open $myoutfile\n";
open(IN,"$myfile"

or die "cannot open $myfile\n";
my $linecounter=0;my $lineread;
while(<IN>){
if($linecounter){print OUT "$lineread";$lineread=$_;}
$linecounter++;}
close(IN); close(OUT);
The first time linecounter=0, so it will just increment linecounter.
The second time, linecounter=1, but lineread is the (undefined) null string(no newline). So the code prints to OUT the null string. The next time through to this line
the 2nd line is appended
The last line is never printed(stored in lineread, but not printed)
This is elegant, but if you want something simpler
and do not have BIG files(that do not fit in your RAM)
you can do this
my @lines=<IN>;
shift @lines; #get rid of first line;
pop @lines; #get rid of last line
foreach my $line(@lines){#NOW print
print OUT "$line\n";}
Hope this helps
svar
print $lineread if $linecounter; #takes care of 1st line
$linecounter++;$lineread=$_;}
next if $linecounter==1;