Hi, may be you could try to complement the following line of code:
chomp $line;with this additional one:
$line =~ s/\r//g;The reason I am suggesting this is that, if I understand correctly what you get, you may be using a Windows file under Unix/Linux or another similar partly incompatible combination.
In this case, chomp is not enough to clean your data from additional invisible characters. Without going into all the details, Windows new lines are composed of two characters (\r\n) and Unix of only one (\n). If you process a Windows file under Unix, Perl believes it is a Unix file and chomp removes the \n character, leaving the \r. In terms of old typewriters or teletypes, \n is the line feed character, whereas \r the carriage return character. If you are left with only the \r character, then the next line may partly overwrite the last one. The ASCII codes for those 2 characters are 10 and 13.
This is just one hypothesis, but your description of the problem makes it quite similar to problems I have encountered a number of times dealing with different platforms. Normal FTP in ASCII mode between platform usually handles the conversion, but binary FTP mode or SFTP often sc*w things up.
I have made my description on differences between Unix and Windows, but you can get similar issues between Mac and Windows, Unix and Mac, VMS and Unix, etc.
In reply to Re: Leading Characters Not Visible for Certain Array Elements While Printing
by Laurent_R
in thread Leading Characters Not Visible for Certain Array Elements While Printing
by justsomeguy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |