sub try(&$) { my ($try, $catch) = @_; eval { # perl try &$try }; if($@){ # perl catch local $_ = $@; &$catch(); } } sub catch(&){ $_[0]; }