use strict; # always # The hash that we'll populate my %value_of; # You have to open the file and read it... my $file = "your file name"; open(FILE, "<", $file) or die "Cannot read '$file': $!"; my $last_variable; while () { # Remove the newline chomp; if (s/^\s+//) { # This was indented, assign it to the hash $value_of{$last_variable} = $_; } else { # This was not indented, it was a variable name $last_variable = $_; } } # %value_of now has the data.