use strict;
use warnings;
my $data = {};
$data->{foo} = { a => 1};
$data->{bar} = "";
if ( %{ $data->{foo} } ) { ... } # ok, because $data->{foo} is a hashref
if ( %{ $data->{bar} } ) { ... } # not ok, because $data->{bar} is empty
####
if ( ref($data->{bar}) eq "HASH" ) { ... } # ok, even if $data->{bar} is empty/undef
####
...
next unless ref($coordinates->{$group}{$id}{$stage}{"coords"}) eq "HASH";
# print individual and coordinate information