Thread prototypes (try/catch) (3 answers)
Opened by betterworld at 2003-09-24 23:39

betterworld
 2003-09-24 23:39
#55989 #55989
User since
2003-08-21
2613 Artikel
ModeratorIn

user image
Hallo,
ich habe da in perlsub gelesen, wie man try-catch implementieren koennte. Ich finde das aber etwas komisch insofern, als dass da im Prototyp &@ steht, obwohl doch ueberhaupt kein Array als zweites Argument uebergeben wird. Vielmehr scheint er sich die catch-Anweisung daherzuholen... peil ich nicht.
Danke fuer Erklaerung

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
           sub try (&@) {
my($try,$catch) = @_;
eval { &$try };
if ($@) {
local $_ = $@;
&$catch;
}
}
sub catch (&) { $_[0] }

try {
die "phooey";
} catch {
/phooey/ and print "unphooey\n";
};

View full thread prototypes (try/catch)