substitue the newlines with spaces, otherwise
this is line one rous is the first word of line two
will become
this is line onerous is the first word of line twowhich is not what you want
open my $fh, "<", "test" or die "test: $!" while (<$fh>) { chomp; $s .= " $_"; }
or shorter
my $s = join " " => split m/\n/ => do { local (@ARGV, $/) = "test"; <> };Or even shorter
my ($s = do { local (@ARGV, $/) = "test"; <> }) =~ s/\n+/ /g;In reply to Re: Splitting a Sentence
by Tux
in thread Splitting a Sentence
by ardibehest
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |