Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Problem with files read to array split on empty lines

by davido (Cardinal)
on Aug 03, 2012 at 07:39 UTC ( [id://985174]=note: print w/replies, xml ) Need Help??


in reply to Problem with files read to array split on empty lines

What operating system were the files created on? What operating system is your local server running, and what operating system is the remote system running?

Write a small script that slurps a file, and then uses tr/\015// and tr/\012// to count independently how many carriage returns and line-feeds the files have. You might find that at least one of the files has line endings that are incompatible with one of the operating systems you're using.

Perl's \n is a logical newline, that can consist of \012, \015\012, or \015, depending on which OS your script is running under (*nix, Win, or Mac). If the file was created or edited on an OS that uses different line endings, you could get errant behavior when reading and dealing with the file. perlport


Dave

Replies are listed 'Best First'.
Re^2: Problem with files read to array split on empty lines
by jhoop (Acolyte) on Aug 03, 2012 at 19:19 UTC

    Thanks very much for the input. The files were created on the same Linux server on which the script was originally attempted. They were downloaded to my Win7 machine via the cPanel web UI. I will test your suggestions on the remote system and report back. I do not imagine it would do much good to test it on the local system, because if tobyink is correct the line endings could have been converted upon downloading the files.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-24 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found