http://qs321.pair.com?node_id=11136432


in reply to Problem printing @arrays

I suspect you are reading a file created with \r\n (carriagereturn-linefeed) line endings (e.g., on a Windows system) on a system (e.g., *nix) that uses \n (linefeed) line endings. On the reading system, the line-feed is chomp-ed off leaving the carriage-return. This can be simulated with something like:

Win8 Strawberry 5.8.9.5 (32) Fri 09/03/2021 23:52:22 C:\@Work\Perl\monks >perl use strict; use warnings; use Data::Dump qw(dd); my $data = <<"EOD"; AA\r AAH\r AAHED\r AAHING\r AAHS\r AAL\r ZYTHUMS\r ZYZZYVA\r ZYZZYVAS\r ZZZ\r ZZZS\r EOD open my $fh, '<', \$data or die $!; my @words = <$fh>; close $fh; dd \@words; chomp @words; dd \@words; print "@words\n"; ^Z [ "AA\r\n", "AAH\r\n", "AAHED\r\n", "AAHING\r\n", "AAHS\r\n", "AAL\r\n", "ZYTHUMS\r\n", "ZYZZYVA\r\n", "ZYZZYVAS\r\n", "ZZZ\r\n", "ZZZS\r\n", ] [ "AA\r", "AAH\r", "AAHED\r", "AAHING\r", "AAHS\r", "AAL\r", "ZYTHUMS\r", "ZYZZYVA\r", "ZYZZYVAS\r", "ZZZ\r", "ZZZS\r", ] ZZZSYVAS


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Problem printing @arrays
by Anonymous Monk on Sep 04, 2021 at 04:30 UTC
    you forgot to give a solution... :crlf
Re^2: Problem printing @arrays
by sbrothy (Acolyte) on Sep 04, 2021 at 15:51 UTC

    I'll have to study this a little more. The dd command isn't what I would call intuitive. I'm sure, though, that I'll learn something by it I cannot learn any other way; much like holding a cat by the tail :)

    Regards, sbrothy.