Perl program to read from multiple files

Hi,

I need to generate a test data file by reading inputs from multiple files.

A sample pseudo code for this program to read from three files and write to a output file would be like:

open(OUTPUTFILE, "data");
open(INFILE1, "data1");
open(INFILE2, "data2");
open(INFILE3, "data3");

while(<OUTPUTFILE>) {
print OUTPUTFILE "the current line of data1" "the current line of data2" "the current line of data2";
}

Is it possible to do something like this in Perl??

Thanks in Advance..
JYoti

Why not? Just try something like, after open (untested)

while (
$l1 = <INFILE1> ||
$l2 = <INFILE2> ||
$l3 = <INFILE3>
) {
print OUTFILE qq/$l1 $l2 $l3/;
}

But of course, you need to keep track of whether any of the filehandles has reached EOF and intelligently skip them in practice.