%hash = (); open (AN, $ARGV[0] ) or die "Not Found\n"; open (IN, $ARGV[1]) or die "Not Found\n"; while ($line = ) { chomp $line; ($k, $v) = split / /, $line; $hash{$k} = $v; } while () { chomp; push (@text, split /\n/); } for $sentence ( @text ) { @word = split / /, $sentence; print $hash{$_},',' for @word; print '0,' for 5 - @word; print "\n"; }