R
Ray
I'm working on a Perl script that reads a text file. The file could have
multiple new lines together, could have lots of spaces between words, tabs,
and so on. Bottome line, I want to end up with the text from the file all
in a single line, with nothing but single spaces between words.
So my Perl script reads the file into an array and puts the lines together
with join. That much is good. From what modest amount I know about regular
expressions, I'd expect to be able to get the extra spaces out this way:
$text =~ s/\s+/ /g;
....but I seem to be wrong to expect that.
How can I get what I want?
multiple new lines together, could have lots of spaces between words, tabs,
and so on. Bottome line, I want to end up with the text from the file all
in a single line, with nothing but single spaces between words.
So my Perl script reads the file into an array and puts the lines together
with join. That much is good. From what modest amount I know about regular
expressions, I'd expect to be able to get the extra spaces out this way:
$text =~ s/\s+/ /g;
....but I seem to be wrong to expect that.
How can I get what I want?