#!/usr/bin/perl use strict; use warnings; my %elements = (); my $input = $ARGV[0]; my $cnt=0; open (my $fh, '<', $input) or die("ERROR open $input ($!)\n"); while(my $line=<$fh>) { chomp($line); my ($id,@words) = split /\s+/, $line; $elements{$id}=\@words; $cnt++; if ($cnt % 1000000 == 0) {print "read another 1000000 lines!\n";} } close($fh); while( my ($k, $v) = each %elements ) { print "key: $k, value: ".join(', ',@$v).".\n"; }