# today's data -- your starting point
my %SHIPS = (
SHIP1 => [
{datetime => '20080318-0730', latitude => '10.33', longitude => '-05.45'},
],
# other ships
);
####
use Data::Dumper;
print Data::Dumper::Dumper([\%SHIPS],[*SHIPS]); # save to file, don't print
####
my %SHIPS;
do 'dumped_file';
####
while (<$CSV>) {
chomp;
# assume csv is SHIP1,DATETIME,LATITUDE,LONGITUDE.
# modify accordingly..
my ($shipname, $datetime, $latitude, $longitude) = split(/\,/$_);
my %today_details = (datetime => $datetime, latitude => $latitude, longitude => $longitude); # this is what will get pushed on the arrayref
my @arr = @{$SHIPS{$shipname} || []}; # get curr contents
push (@arr, \%today_details); # push today's data
$SHIPS{$shipname} = \@arr; # push back
}
# that's you done with the merge