$VAR1 = [ { 'xml_api_reply' => { '-version' => '1', 'weather' => { '-row' => '0', 'current_conditions' = +> { + 'icon' => { + '-data' => '/ig/images/weather/mostly_cloudy.gif' + }, + 'temp_f' => { + '-data' => '73' + }, + 'temp_c' => { + '-data' => '23' + }, + 'wind_condition' => { + '-data' => 'Wind: NW at 6 mph' + }, + 'humidity' => { + '-data' => 'Humidity: 73%' + }, + 'condition' => { + '-data' => 'Mostly Cloudy' + } + }, , 'forecast_information' + => { + 'forecast_date' => { + '-data' => '2012-08-16' + }, + 'city' => { + '-data' => 'Miami, FL' + }, + 'latitude_e6' => { + '-data' => '' + }, + 'postal_code' => { + '-data' => '02151' + }, + 'current_date_time' => { + '-data' => '2012-08-16 12:54:00 +0000' + }, + 'longitude_e6' => { + '-data' => '' + }, + 'unit_system' => { + '-data' => 'US' + } + }, } } }, { 'xml_api_reply' => { '-version' => '1', 'weather' => { '-row' => '0', 'current_conditions' = +> { + 'icon' => { + '-data' => '/ig/images/weather/mostly_cloudy.gif' + }, + 'temp_f' => { + '-data' => '73' + }, + 'temp_c' => { + '-data' => '23' + }, + 'wind_condition' => { + '-data' => 'Wind: NW at 6 mph' + }, + 'humidity' => { + '-data' => 'Humidity: 73%' + }, + 'condition' => { + '-data' => 'Mostly Cloudy' + } + }, 'forecast_information' + => { + 'forecast_date' => { + '-data' => '2012-08-16' + }, + 'city' => { + '-data' => 'Boston, MA' + }, + 'latitude_e6' => { + '-data' => '' + }, + 'postal_code' => { + '-data' => '01908' + }, + 'current_date_time' => { + '-data' => '2012-08-16 12:54:00 +0000' + }, + 'longitude_e6' => { + '-data' => '' + }, + 'unit_system' => { + '-data' => 'US' + } + }, } } }, ];
my $test_data = $data[0]{'xml_api_reply'}{'weather'}{'forecast_informa +tion'}{'city'}->{"-data"};
.... 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_infor +mation'}{'city'}->{"-data"}; print "$test_data\n"; } close $fh;
In reply to Open and parsing a file with array of hashes!? by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |