in reply to undefined or zero: looking for an elegant solution
Assuming you truly mean defined and not exists:
(thanks to JavaFan for the tip on using "eq '0'")$nr = $metricOpenTasks{$relWeek}{$cc}{'nr'} // 1; $nr = 1 if $nr 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:
but that doesn't make any sense now does it?$nr = (($metricOpenTasks{$relWeek}{$cc}{'nr'} // 0) =~ /^($|[^0]|0.)/) +[0] // 1;
|
|---|