my %h; for my $file ( glob "*.[abc]" ) { my( $file_k0, $file_k1 ) = $file =~ /(.*)\.(.*)/; local @ARGV = ($file); while (<>) { chomp; push @{ $h{$file_k0}{$file_k1} }, [ split /\t/ ]; } }