# Work out which mode we're in my $mode = param('mode'); # If we have a mode, then call that subroutine if ($mode && %modes{mode}) { $modes->{mode}->(); } else { # Otherwise call the default handler $modes->{default}->(); }