Re: printing sentences on the same line

2008-01-12 Thread John W. Krahn
Gunnar Hjalmarsson wrote: John W. Krahn wrote: Could you please explain how the code I posted does not accomplish the OP's objectives or is inefficient? Well, to me it seems like the pre-defined sentences, including the undesired newline symbols, are not part of the data that is read by the

Re: printing sentences on the same line

2008-01-12 Thread Gunnar Hjalmarsson
John W. Krahn wrote: Gunnar Hjalmarsson wrote: John W. Krahn wrote: A more efficient method is to read and write one line at a time: $\ = ' '; # set Output Record Separator to a space while ( <> ) { $\ = "\n" if eof; chomp; print; } That may be an efficient solution to some

Re: printing sentences on the same line

2008-01-12 Thread John W. Krahn
Gunnar Hjalmarsson wrote: John W. Krahn wrote: Ryan wrote: Gunnar Hjalmarsson wrote: 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"; This

Re: printing sentences on the same line

2008-01-12 Thread Gunnar Hjalmarsson
John W. Krahn wrote: Ryan wrote: Gunnar Hjalmarsson wrote: 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"; This approach did the job. Than

Re: printing sentences on the same line

2008-01-12 Thread John W. Krahn
Ryan wrote: Gunnar Hjalmarsson wrote: 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"; This approach did the job. Thanks. A more effici

Re: printing sentences on the same line

2008-01-12 Thread Ryan
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 construct, one line at a time, and prints different pre-defined

Re: printing sentences on the same line

2008-01-07 Thread Gunnar Hjalmarsson
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 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

Re: printing sentences on the same line

2008-01-06 Thread yitzle
In addition to what Chas said, you may also want to add a space after each sentence. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: printing sentences on the same line

2008-01-06 Thread Chas. Owens
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 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 progra