On Thursday, November 6, 2003, at 11:13 AM, Tore Aursand wrote:

On Thu, 06 Nov 2003 10:31:18 -0600, James Edward Gray II wrote:
my @results;
[...]

Wasn't it the whole point that the OP _couldn't_ store this in an array,
as it would consume too much memory? The solution goes like this;

You are correct, of course. I had forgotten this and as the test data he posted wasn't anywhere near a problem, I opted for the simple way out. Thanks for keeping me honest.


James

#!/usr/bin/perl

use strict;
use warnings;

my @files;
my $index = 0;
for my $file (qw(file1 file2 file3 file4)) {
        open $files[$index++], '<', "$file.txt" or die "Input error:  $!\n";
}
open OUT, '>', 'combined.txt' or die "Output error:  $!\n";

do {
        my @line;
        foreach my $file (@files) {
                my $line = <$file>;
                $line[length $1] = $2 if defined($line) && $line =~ /^(;*)(\d+)/;
        }
        {
                no warnings 'uninitialized';
                print OUT join(':', @line), "\n";
        }
} until (eof $files[0]);

close $_ foreach @files;
close OUT;


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to