my %hosts = map{ split /\s+/, $_, 2 }; # Or substitute your favourite filehandle here. __DATA__ host1 1.1.1.1 host2 1.2.3.5