0

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.

Thanks.

1
  • It isn't clear what output you want. Surely there should be is: in there somewhere? I think you should show your Perl program so that we can help you properly Commented Apr 21, 2015 at 12:16

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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//

1 Comment

Heya, thanks... I have been using conf file taken from windows and running on Linux. Dint know about this thing. Thank you :) @borodin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.