... open (FILE, ">data.txt") or die "can't open file: $!"; my $weather_data = do "data.txt"; ... #### #! perl use strict; use warnings; use Data::Dumper; use Date::Format; { my $file = 'data.txt'; my $today = get_timezone(); my $weather_data = do $file; ${ $weather_data->[0]{xml_api_reply}{weather} }{report_date} = { '-data' => $today }; open(my $out, '>', $file) or die "Cannot open file '$file' for writing: $!"; print $out Dumper($weather_data); close($out) or die "Cannot close file '$file': $!"; } sub get_timezone { $ENV{'TZ'} = 'America/New_York'; return time2str('%m-%d-%Y @ %H:%M:%S', time); } #### $VAR1 = [ { 'xml_api_reply' => { '-version' => '1', 'weather' => { 'report_date' => { '-data' => '08-20-2012 @ 18:50:16' }, '-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' }, 'condition' => { '-data' => 'Mostly Cloudy' }, 'humidity' => { '-data' => 'Humidity: 65%' } } } } } ];