Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!fed!arccs2!m1dib00 From: m1dib00@fed.frb.gov (Douglas I. Battenberg) Newsgroups: comp.lang.perl Subject: extra line mystery Message-ID: Date: 5 Jul 90 15:18:00 GMT Sender: news@fed.FRB.GOV Distribution: comp.lang.perl Organization: Federal Reserve Board Lines: 44 The following script reads a file, edits some lines, and prints the whole thing back into a new file. The problem is the output file ends up with an extra blank line at the end. If I count lines and print the array with a for loop, I get the correct number of lines. I've monitored this with the debugger but cannot see where the extra line is coming from. What am I missing here? #! /usr/bin/perl $\="\n"; # set automatic newline for print statements $| = 1; # clear buffers $* = 1; # do multi string matches ;# initialize arrays @model_cards = (); @judge_cards = (); open(modelcc,"/mq/mps/qmod/data/cards/model"); chop(@model_cards = ); # read model cards into an array @judge_cards = @model_cards; ;# create judge cards from model cards $lines = $#judge_cards; $last_line = $judge_cards[$#judge_cards]; for ($i = 0; $i <= $#judge_cards; $i++) { $_ = $judge_cards[$i]; s|actfit/model|actfit/judge|ig; $judge_cards[$i] = $_; } open(judgecc,">/mq/mps/qmod/data/cards/judge"); print(judgecc @judge_cards); close(modelcc); close(judgecc);