while (<>) { # next if /^ID/; chomp; ($table = fileparse $ARGV) =~ s/\.txt$// unless $table; $col_cnt{$table} ||= tr/|//; my ($gene, $cols) = split /\s*\|\s*/, $_, 2; $data{$gene}{$table} = $cols; $table = '' if eof; }