This approach did the job.  Thanks.

--Chris Ryan

Gunnar Hjalmarsson wrote:
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.


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";


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to