.... my %hash; open my $fh, '<', 'weather.txt' or die "Cannot open: $!"; while (my $lines = <$fh>) { my @data = $lines; my $key = shift @data; my $test_data = $data[0]{'xml_api_reply'}{'weather'}{'forecast_information'}{'city'}->{"-data"}; print "$test_data\n"; } close $fh;