Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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

by davido (Archbishop)
on Aug 03, 2012 at 07:39 UTC ( #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


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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://985174]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2018-03-20 06:56 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (248 votes). Check out past polls.