catch { ... } is invoked before the block in the try { ...}, and all it does is to return the block as a reference to the anonymous function defined by the catch block.#!/usr/bin/env perl sub try(&$) { my ($try, $catch) = @_; eval { # perl try &$try }; if($@){ # perl catch &$catch($@); } } sub catch(&){ shift } try{ die("Frankie"); } catch { my $e = shift; print("Hello world $e\n"); }
In reply to Re^2: Perl try { } catch(e) { }
by Superfox il Volpone
in thread Perl try { } catch(e) { }
by Superfox il Volpone
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |