in reply to undefined or zero: looking for an elegant solution

Assuming you truly mean defined and not exists:

$nr = $metricOpenTasks{$relWeek}{$cc}{'nr'} // 1; $nr = 1 if $nr eq '0';
(thanks to JavaFan for the tip on using "eq '0'")

No good way around splitting it into two lines because of checking for the special case of ''. I s'pose you could do something sick like:

$nr = (($metricOpenTasks{$relWeek}{$cc}{'nr'} // 0) =~ /^($|[^0]|0.)/) +[0] // 1;
but that doesn't make any sense now does it?