Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Can read one txt file and not another?

by GrandFather (Saint)
on Jul 29, 2021 at 02:59 UTC ( [id://11135456]=note: print w/replies, xml ) Need Help??


in reply to Can read one txt file and not another?

Why don't you show us samples of the two versions of the text? Start with a very short first text file containing a few words and new lines, then process that to produce the broken version. We can make lots of guesses about how the text files might be wrong and waste our time and yours doing so. Showing us a small sample of what you are actually dealing with will save everyone time and get you a much better answer.

Why do you read the first line into $in then do nothing with it? Could that be related to your problem?

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^2: Can read one txt file and not another?
by Anonymous Monk on Jul 29, 2021 at 04:41 UTC

    Well, I feel silly now. Removing $in appears to have fixed the problem unless it was something seemingly unrelated I did later in the code that did it (but I doubt that). I started with an old code I wrote years ago (took a course that included some Perl and then forgot it) and changed a lot but just hadn't taken $in out.

    Thanks for the help! I was expecting something more complicated and missed a very simple solution.

      Removing $in appears to have fixed the problem unless it was something seemingly unrelated I did later in the code that did it (but I doubt that).
      If I'm understanding your post correctly, it's completely relevant.

      The file that didn't work had all the newlines removed, making the entire file a single line. Since there was only one line in the file, reading the first line into $in and throwing it away... threw away the entire file, leaving nothing for the loop to read.

      This isn't stack overflow, if you find a solution on your own it's appreciated if you provide it with the different data that would be needed to explain it. Real people spend real time on others' problems. Although it's voluntary and a labor of love for some, it is nonetheless appropriate to "wrap up" things. Not only that, PM has the largest collection of the most complicated and interesting Perl questions and solutions in the world. Adding a wrap up will make this post potentially assist another in the future. Right now it's lacking: data requests (from others) and the solution.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-28 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found