any of the array elements when printed act as if they have a new line. So it would be the last array element printed. In the case it could be 3 but it could also be 2 or 4.
> -----Original Message----- > From: Dan Muey [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 16, 2003 10:49 AM > To: Paul Kraus; Perl > Subject: RE: Where is the new line coming from. > > > > I am reading in a text file that has input similar to this. > > date|data|data|data\n > > > > I then read the file in and using a while loop I chomp off > > the new line. while (<IPO>){ > > chomp; > > @line=split /\|/,$_; > > $line[2]=~s/ //g; > > Do you mean $line[3] since that is the last one in the array > in the example above? > date1|data2|data3|data4\n would become > 0 data1 > 1 data2 > 2 data3 > 3 data4\n > If so remove any newlines and space also : > $line[3] =~ s/\n|\r| //g; > Or use '\s' instead of ' ' for the space. > > Dan > > print "$_" foreach (@line); > > last; > > $count++; > > last if ($count == 7); > > } > > > > Here is the mystery. the output has a newline at the end of > > it. It should print > > "data data data data" and then my next prompt should be right > > here. instead it prints > > "data data data data > > "and my prompt is here. > > > > If I remove the initial chomp then I get a double space at the end. > > > > No matter what I print the last element gets a new line ????? > > > > Example if I > > print "$line[0] $line[1]"; > > then right at the end of the print statement is a new line > > and the output is identical to what I previously described. > > the last elements always inherits a new line. It driving me > > crazy!!! thanks in advance :) > > > > > > Paul Kraus > > Network Administrator > > PEL Supply Company > > 216.267.5775 Voice > > 216-267-6176 Fax > > www.pelsupply.com > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]