![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| read list of filenames from text file and remove these files in multiple directories | fxvisions | Shell Programming and Scripting | 5 | 08-07-2008 03:59 PM |
| read and match multiple lines in perl | zx1106 | Shell Programming and Scripting | 5 | 03-14-2008 10:21 PM |
| Multiple Files deletion in perl | pulkit | Shell Programming and Scripting | 1 | 02-12-2008 05:55 AM |
| How to read from multiple files | cedrichiu | Shell Programming and Scripting | 5 | 07-10-2007 11:49 AM |
| Splitting my program to multiple source files. | the_learner | High Level Programming | 6 | 06-04-2007 10:53 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|