Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use CGI qw(-oldstyle_urls :standard); use Data::Dumper; use Date::Format; use Date::Parse; my $q = new CGI; $| = 1; my @data; my $today = get_timezone(); #set $Data::Dumper::Purity to 1 if you have nested references #$Data::Dumper::Purity = 1; open (FILE, ">data.txt") or die "can't open file: $!"; my $weather_data = do "data.txt"; for my $w_data (@$weather_data) { push @data, \$w_data; } push @data, {$data[0]{'xml_api_reply'}{'weather'}{'report_date'}->{'-d +ata'} = $today,}; print FILE Dumper(\@data); close FILE or die "can't close file: $!"; sub get_timezone { ### Get our local time. $ENV{'TZ'} = 'America/New_York'; $today = time2str( "%m-%d-%Y \@ %H:%M:%S", time); }
$VAR1 = [ { 'xml_api_reply' => { '-version' => '1', 'weather' => { '-row' => '0', 'current_conditions' = +> { + 'icon' => { + '-data' => '/ig/images/weather/mostly_cloudy.gif' + }, + 'temp_f' => { + '-data' => '70' + }, + 'temp_c' => { + '-data' => '21' + }, + 'wind_condition' => { + '-data' => 'Wind: E at 7 mph' + }, + 'humidity' => { + '-data' => 'Humidity: 65%' + }, + 'condition' => { + '-data' => 'Mostly Cloudy' + } + }, } } }, ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Odd number of elements in anonymous hash!
by NetWallah (Canon) on Aug 19, 2012 at 17:37 UTC | |
by Anonymous Monk on Aug 19, 2012 at 18:07 UTC | |
by NetWallah (Canon) on Aug 19, 2012 at 19:07 UTC | |
by Anonymous Monk on Aug 19, 2012 at 19:44 UTC | |
by Athanasius (Archbishop) on Aug 20, 2012 at 09:08 UTC |