Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^4: I'm having a strange bug with basic file input. I'm a total newb.by jethro (Monsignor) |
on Dec 05, 2008 at 12:57 UTC ( [id://728273]=note: print w/replies, xml ) | Need Help?? |
Post the updated code if it still doesn't work. Otherwise we can't help because we don't know what you did. But first read on: The thing about the line terminators: Every line in a file has a special character at the end that says "Here is the end of the line". Thats the \n. You already use this character when you print lines so you probably know this. In your program you read each line, but not the \n at the end. Consequently when you read the second line of the file you have that character at the beginning, you are out of sync with your input file. That means you have to read that line ending from the file too even though you don't really need it. You can do that with <INPUT> which you have to put into two places, before the loop after the first line reading and inside the loop after the line reading. That is in a lot more words what almut tried to tell you. If you apply that correctly you should see an improvement
In Section
Seekers of Perl Wisdom
|
|