Your input data probably contains an extra \r that is not removed by chomp. You can see that with Data::Dump:
One of the ways this can happen is when you try to read a file created on Windows with perl running on Linux, or a Cygwin perl.use Data::Dump qw( pp ); # some code here print pp \@ip; chomp(@ip); print pp \@ip;
You can correct that by explicitly setting the input record separator to the CRLF format:
my @ip; { local $/ = "\r\n"; # because this is local, the normal behaviour is +restored after this block open my $dat, "<", $in_file or die "Can't open file $in_file: $!"; @ip = <$dat>; chomp(@ip); close $dat; }
In reply to Re: problem in printing the result in the out put file
by Eily
in thread problem in printing the result in the out put file
by hegaa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |