in reply to Re^2: reading N files
in thread reading N files

So, if you happened to be on a *n*x box (or have a windows port of standard unix utilities), you could just do a shell command (that includes a perl one-liner):
# assuming N files are named in some systematic way, # and columns are separated by whitespace: paste file.* | perl -pe '($t)=(/^(\S+)/); s/\t$t//g;' > multi-column.f +ile
The unix "paste" command takes a list of file names and concatenates them "horizontally", line by line; for a list of input files (1..N), its default behavior replaces the newline with a tab for each line of files 1..N-1.

Assuming that all files in the set have the same series of values in the first column, the perl script removes all but the first occurrence of that value on each line. (If all these assumptions don't apply, then your approach of reading from a set of file handles in a loop is fine, of course.)

Replies are listed 'Best First'.
Re^4: reading N files
by gri6507 (Deacon) on Jul 20, 2006 at 12:24 UTC
    I didn't know about the paste command. I'll have to keep it in mind in the future. However, it would not have worked in my scenario. One of the problems is that that values in the first column may or may not be the same series, making the merging step a bit more difficult.