Re: Joining 2 strings

From: Sim (selena_kid_at_yahoo.com)
Date: 08/11/04


Date: 10 Aug 2004 15:51:24 -0700

I managed to solve the problem! It is very similar to the solution Jue
posted. Here's how it goes. I wish to thank everyone who has thought
through this problem. My MSN is jjsimz@hotmail.com. I am a college
Physics student, and if you have any physics question, I might be of a
little help. =)

#!/usr/bin/perl
use strict;

open (FILE, 'sample.out') or die "could not open 'sample.out'!!! ";
open (OUTPUTFILE, '>>output.out') or die "could not open
'output.out'!!! ";
while (<FILE>) {
        s/^\s*((.*\S)?)\s*$/$1/; #removes spaces before and after the
string
        print (OUTPUTFILE $_, ' ');
        if ($. % 3 == 0) {print (OUTPUTFILE "\n")}
}
close FILE;
close OUTPUTFILE;