Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


in reply to Re^3: I'm having a strange bug with basic file input. I'm a total newb.
in thread I'm having a strange bug with basic file input. I'm a total newb.

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://728273]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-03-29 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found