my @array = (1, 2, 3, 4, 5, 6); my %hash = @array; #### my %hash = ( 1 => 2, 3 => 4, 5 => 6 ); #### open my $file, '<', $filename or die "Unable to open '$filename': $!"; my %edit; for (<$file>) { next if //; chomp; # Some code to get a $key with an appropriate value $edit{$key} = $_; } close $file;