|Pathologically Eclectic Rubbish Lister|
Chomp is removing the whole word instead of the newlineby slayedbylucifer (Scribe)
|on Jul 25, 2012 at 09:27 UTC||Need Help??|
slayedbylucifer has asked for the
wisdom of the Perl Monks concerning the following question:
I am facing issues with perl chomp function. I have a test.csv as below:
I want to print the 2nd field of this csv. This is my code:
The output of aboe code is :
I really don't know what is "11111". Actually, the last field can be printed as below:
the output is:
Now, i am using these field values as an input to the DB and the DB INSERT statement is failing due this invisible newline. So I thought chomp would help me here. instead of chomping, it gives me "11111".
I also tried below loop:
But above loop will not print anything (not even the "11111" output mentioned above). Meaning, chomp is removing the last string and the trailing new line.
Could you help me understand what am i doing wrong here.
Also please find my discussion on stackoverflow for this issue: http://stackoverflow.com/questions/11645696/perls-chomp-chomp-is-removing-the-whole-word-instead-of-the-newline