On Wed, Jul 22, 2009 at 18:04, Owen<rc...@pcug.org.au> wrote: snip > It works for me. So try this snip
Try this, it simulates what is probably happening: #!/usr/bin/perl use strict; use warnings; my $fakefile = "6754\r\n7890\r\n6543\r\n"; open my $fh, "<", \$fakefile or die "could not open the fake file: $!"; my @array; while (my $line = <$fh>) { chomp $line; push @array, $line; } print "@array\n"; a quick change to get rid of the carriage returns fixes the problem: #!/usr/bin/perl use strict; use warnings; my $fakefile = "6754\r\n7890\r\n6543\r\n"; open my $fh, "<", \$fakefile or die "could not open the fake file: $!"; my @array; while (my $line = <$fh>) { $line =~ s/[\r\n]//g; push @array, $line; } print "@array\n"; This mostly comes up when data is transferred from Windows machines (where end-of-line is carriage return and line feed) to UNIX machines (where end-of-line is just line feed). The carriage return causes the terminal cursor to go back to the start of the line, so the print keeps overwriting the numbers. You can see what is actually being printed out by saying perl script.pl | cat -e This prints out something like: 6754^M 7890^M 6543^M$ Another option is to use od: perl script.pl | od -a which prints out 0000000 6 7 5 4 cr sp 7 8 9 0 cr sp 6 5 4 3 0000020 cr nl 0000022 -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/