in reply to split on newline

my @words = <>; chomp(@words); print(join(';', @words), "\n");

As a one-liner:

perl -nle'push @w, $_; END { print join ";", @w }'

-l inserts a chomp; into -n's (and -p's) loop.

Replies are listed 'Best First'.
Re^2: split on newline
by tbone654 (Beadle) on Sep 12, 2014 at 20:02 UTC
    That works... the -l is the secret, thank you... I was chomp'ing it manually yesterday and it was blowing up...
      It's not the chomping that was blowing up your code.
      perl -nle' push @w, $_; END { print join ";", @w } '
      is the same as
      perl -ne' BEGIN { $\ = "\n"; } chomp; push @w, $_; END { print join ";", @w } '

      You had some other problem yesterday. chomp-ing 'manually' won't blow anything up.