my $rc; given($ex) { when($ex->isa("MyException::Class1")) { $rc = 1; } when($ex->isa("MyException::Class2")) { $rc = 2; } default { $rc = 3 } } # and now pass on $rc to a template