[HOME] [NSRG] [インフラ] [fml4] [fml8] [北海道] [おすすめの本] Powered by NetBSD and [nuinui.net] .

Exceptions or long jump mechanism

In python, you can use this style.

try:
   statements
except name:
   statements
else:
   statements
On oontrary, perl has this style. But perl has eval $@ form. Please use this.
# try
eval {
   statement;
   croak(""); # raise
}
# except
unless ($@) {
   statements for exception;
}
# else 
else {
   statements;
}

There is a perl module which provides catch and throw style. But we do not use this.

throw info from croak().

How to throw up info from croak() ?

One style is

croak("__ERROR_$keyword__");
croak("__ERROR_$keyword__: $reason");
For example,
croak("__ERROR_cgi.insecure__: $reason");
$keyword is the key of this message. But how about parameters for the key ? hmm, ...

[HOME] [NSRG] [インフラ] [fml4] [fml8] [北海道] [おすすめの本] Powered by NetBSD and [nuinui.net] .
Copyright (C) 1993-2017 Ken'ichi Fukamachi mail:< fukachan at fml.org >