in reply to Re^2: from txt file to array
in thread from txt file to array

If you see being "pedantic" (i.e. explicit) as something good (I sometimes do too), then you simply should avoid punctuation variables and implicit arguments altogether:
my @myarray; while (my $item = <DATA>) { chomp $item; push @myarray, $item; }
But here my taste would be a more functional idiom:
my @myarray = map { chomp; $_ } <DATA>;

Replies are listed 'Best First'.
Re^4: from txt file to array
by karlgoethebier (Abbot) on Jun 22, 2017 at 08:36 UTC

    More untested func to avoid empty slots:

    my @myarray = map { chomp; $_ } grep { $_ ne "" } <DATA>;

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    Furthermore I consider that Donald Trump must be impeached as soon as possible