#!/usr/bin/perl %hash; while (){ chomp; ($key, $value)= split(/[\s+|\t+]/,$_); $hash{$key}=$value; } foreach $key2 (keys %hash){ print "$key2 -> $hash{$key2}\n"; } __DATA__ a 1 a 2 a 1 a 3