use Data::Dumper; open(FILE1, $ARGV[0]) or die "Cannot open the file: $!"; my %hash1 = split ' ', do{ local $/; }; close FILE1; print Dumper \%hash1;