Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: parallel reading

by McDarren (Abbot)
on May 09, 2006 at 13:32 UTC ( #548205=note: print w/ replies, xml ) Need Help??

in reply to parallel reading

If we can make the assumption that each file has the same number of lines, then the following should work:

#!/usr/bin/perl -w use strict; my %files; my @infiles = qw(fileA fileB fileC); for (@infiles) { open IN, "<", $_ or die "Cannot open $_:$!\n"; chomp(@{$files{$_}} = <IN>); close IN; } open OUT, ">", "fileD" or die "Cannot open fileD:$!\n"; for my $line (0 .. $#{$files{fileA}}) { for my $file (@infiles) { print OUT $files{$file}[$line]; } print OUT "\n"; } close OUT;
$ cat fileD 111AAAaaa 222BBBbbb 333CCCccc
Darren :)

Comment on Re: parallel reading
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://548205]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2015-11-25 09:29 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (672 votes), past polls