Chas. Owens wrote:
On Jan 6, 2008 7:48 PM, Ryan <[EMAIL PROTECTED]> wrote:
I have a small piece of a program which loops through lines of data,
using the <while> construct, one line at a time, and prints different
pre-defined sentences, contingent upon what is found in each line of
data. The data are in the program file, in a __DATA__ section. I use
the simple print command.
The output looks like this:
This is the first sentence.
This is the next sentence.
And this is the third one.
etc.
I'd like the output to look like this:
This is the first sentence. This is the next sentence. And this is the
third one. etc.
Use chomp() to remove the "\n" on the end of each sentence. Remember
to output at "\n" at the end.
One way to do that is to store the sentences in an output array instead
of printing them directly.
Within the while loop:
push @output, ...;
And then:
chomp @output;
print "@output\n";
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/