Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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


Dave


Comment on Re: Problem with files read to array split on empty lines
Select or Download Code
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
Node Status?
node history
Node Type: note [id://985174]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2014-09-21 06:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (167 votes), past polls