Perl:Combine multiple lines into 1 sentence

March 27, 2010 at 00:17:11
Specs: Linux i686
Hi,
I'm writing a perl script that combine a multiple lines from file into a full sentence. After that, search certain criteria from a sentence. How I can grab this information?

For example, the file contain below text:
#!MLF!#
"*/SAMPLEZ136.rec"
I
WANT
TO
BUY
ONE
TICKET
FROM
STATION
1
TO
STATION
2
.

I want Perl to combine all lines into a sentence. Script will only read line after 'BUY' and before '.' . After that compare with if-else statement. If match it would return:

Price = RM4.00

Anywhere I only now how to read from file but fail to combine lines into sentence.

Sample Code:
open( FILE, "< $filename" ) or die "Can't open $filename : $!";

while( $line = <FILE> )
{
print;}


Can anyone please advise?

Thank you.

Regards,
Ling


See More: Perl:Combine multiple lines into 1 sentence

Report •

#1
March 27, 2010 at 02:14:03
set a variable, eg $s, then as you read each line,
s = s  .  $line ;

GNU win32 packages | Gawk

edited by moderator: Removed partal a tag -Razor 2.3


Report •

#2
March 27, 2010 at 03:12:20
There's something strange with the html here, I think it
may have something to do with the link:

<a href="http://gnuwi</TD</TR</TABLE</BLOCKQUOTE
<A HREF="></a>

Which views as:

<a href="http://gnuwi%3C/TD%3E%3C/TR%3E%3C/TABLE%3E%3C/BLOCKQUOTE%3E%0A%3CA%20HREF="></a>


Report •

#3
March 28, 2010 at 10:45:39
Good lord, can I not go a way for a weekend without Judago pointing out everything that needs fixing? :P (Or: Yes, I do actually perform a service for this board.)

Report •

Related Solutions

#4
March 28, 2010 at 13:40:06
Razor2.3, of course not, in fact you should wake up nights sweating thinking about this place. You can never leave; one of us , one of us, one of..... :)

I drop in for ten minutes on a Sunday night, mention two issues and suddenly I am the problem child....


Report •

Ask Question