in reply to Re: I need help joining tab-delimited files/tables!
in thread I need help joining tab-delimited files/tables!

An alternative solution to the above would be something like this
my @files = ('file1','file2','file3','file4'); # use a glob if you prefer my %hash; foreach my $file_name (@files){ open my $fh, '<',$file_name || die "$!"; while (<$fh>){ chomp; next if (/^\s*$/); my ($id,$val) = split /\t/; $hash{$id}{$file_name} = $val; } close $fh; } foreach my $id (sort keys %hash){ print "$id\t"; print $hash{$id}{$_} ? "$hash{$id}{$_}\t" : "0\t" foreach (@f +iles); print "\n"; }

Replies are listed 'Best First'.
Re^3: I need help joining tab-delimited files/tables!
by NetWallah (Canon) on Oct 20, 2011 at 03:50 UTC
    Your "open" statement has the "Operator precedence" problem described in die on file open.

                "XML is like violence: if it doesn't solve your problem, use more."