Perl Code : Output not displayed properly


I have a perl code where I access multiple txt files and produce output for them. While I run the code, the output lines on the console are overwritten.

2015-04-21:12-04-54|getFilesInInputDir| ********** name : PEPORT ********** PEPORT4-21:12-04-54|readNFormOutputFile| name : PEPORT" is : -04-54|readNFormOutputFile| Frequency for name "

Please note, that the second and third line it should have been like

2015-04-21:12-04-54|readNFormOutputFile| name : PEPORT 2015-04-21:12-04-54|readNFormOutputFile| Frequency for name "PEPORT"

Also, after this the code stops processing my files. The code seems fine. May I know what may be the possible cause for this.



Seems like CR/LF versus LF issue. Convert your input from MSWin to Linux by running dos2unix or fromdos, or remove the "\r" characters from within the Perl code.


As choroba says, I guess you are reading a file on Linux that has been generated on Windows. The easiest fix is to replace chomp with s/\s+\z//or s/\p{cntrl}+\z//

Or, if trailing spaces are significant, you can use s/[\r\n]+\z// or, if you are running version 10 or later of Perl 5, s/\R\z//


  • Using fscanf to read comma delimited doubles
  • why i am getting “Inconsistent ending lines” warning window while executing sql script?
  • Using a function to convert angles from degrees to radians in C
  • CMD-Batch line length. Possible to remove? If not, how to check for too long lines?
  • MASM : How do you declare a string with carriage return?
  • Quick sort Vs. Merge sort Performance Analysis
  • Access violation writing location when reading character via scanf_s
  • Coordinates of points dividing circle into n equal halves in Pebble
  • mysql - removing CHAR(13) CHAR(13)
  • Why aren't my pointers to integer arrays working?
  • FFTW producing real instead of complex output
  • Flat File to retain commas from SQL data
  • TortoiseGit, ignore line endings
  • Parsing XML CDATA with Xmllite
  • subversion svn sync message meaning
  • Will STL deque pop_front() automatically recycle memory?
  • Rotate Text by 90 degrees with GDI
  • how to get the raw version of a template string in iojs
  • C - long double and printf issue
  • CSVParser processes LF as CRLF
  • Bash: How to do a variable expansion within an arithmetic expression?
  • how to sleep accurately in a while loop in C (Linux)?
  • R. how to make matrix which have equal rows
  • Fibonacci Computation Time
  • Retrieve google contact based on contact Id
  • iPython magic for Zipline cannot find data bundle
  • how to execute 50 parallel methods 500 times per second effectively?
  • How do I chomp a string if I have Perl 4?
  • Vim folding : how to hide all the single lines not containing a search pattern (or fold zero line)?
  • Using $this when not in object context
  • How do I fake an specific browser client when using Java's Net library?
  • How reduce the height of an mschart by breaking up the y-axis
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Validaiting emails with Net.Mail MailAddress
  • Perl system calls when running as another user using sudo
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • Javascript + PHP Encryption with pidCrypt
  • How can I estimate amount of memory left with calling System.gc()?
  • Hits per day in Google Big Query
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)