foreach my $o (%{$c}) { if(ref(\$o) eq 'REF' && exists($o->{Device}) && $o->{Device} eq $device) { $o->motion; last; } }