=encoding euc-jp =head1 NAME =begin original carp - warn of errors (from perspective of caller) =end original carp - エラーの警告 (呼び出し元の観点から) =begin original cluck - warn of errors with stack backtrace (not exported by default) =end original cluck - スタックバックトレースを伴うエラーの警告 (デフォルトではエクスポートされません) =begin original croak - die of errors (from perspective of caller) =end original croak - エラーを出して die する (呼び出し元の観点から) =begin original confess - die of errors with stack backtrace =end original confess - スタックバックトレースを伴って die する =head1 SYNOPSIS use Carp; croak "We're outta here!"; use Carp qw(cluck); cluck "This is how we got here!"; =head1 DESCRIPTION =begin original The Carp routines are useful in your own modules because they act like die() or warn(), but with a message which is more likely to be useful to a user of your module. In the case of cluck, confess, and longmess that context is a summary of every call in the call-stack. For a shorter message you can use C or C which report the error as being from where your module was called. There is no guarantee that that is where the error was, but it is a good educated guess. =end original Carp ルーチンは die() や warn() のように振る舞いますが、 あなたのモジュールのユーザーにとってより便利なものとなりそうな メッセージを伴うため、モジュールで用いる際に便利です。 cluck, confess, logmess ではそのコンテキストは コールスタック内の全ての呼び出しに関する要約です。 より短いメッセージのためには C または C を 使うことによって、モジュールが呼び出された位置から エラーを報告できます。 これはエラーがどこで発生したかを保証するものではありませんが、 優れた推測機能を提供します。 =begin original You can also alter the way the output and logic of C works, by changing some global variables in the C namespace. See the section on C below. =end original また、C 名前空間のグローバル変数を変更することで、C の 出力と動作原理を変更できます。 後述する C 節を参照してください。 =begin original Here is a more complete description of how C and C work. What they do is search the call-stack for a function call stack where they have not been told that there shouldn't be an error. If every call is marked safe, they give up and give a full stack backtrace instead. In other words they presume that the first likely looking potential suspect is guilty. Their rules for telling whether a call shouldn't generate errors work as follows: =end original 以下は C と C における動作原理についての完全な説明です。 これらが行うのは、 エラーが存在しないことを伝えていない関数コールスタックの検索です。 もし全ての呼び出しが安全であるとマークされているならば、動作をやめ、 代わりにフルスタックバックトレースを提供します。 言い換えると、真っ先にエラーが起きそうだと 疑うことは罪なことであると考えるのです。 呼び出しがエラーを生成しないはずと判断する規則は次のものです: =over 4 =item 1. =begin original Any call from a package to itself is safe. =end original あるパッケージからそれ自身への呼び出しは安全とします。 =item 2. =begin original Packages claim that there won't be errors on calls to or from packages explicitly marked as safe by inclusion in C<@CARP_NOT>, or (if that array is empty) C<@ISA>. The ability to override what @ISA says is new in 5.8. =end original パッケージは、C<@CARP_NOT> 又は (もしその配列が空ならば) C<@ISA> に 含まれることで明らかに安全なものとしてマークされているパッケージからの、 あるいはパッケージへの呼び出しでエラーが存在しないはずであることを 主張します。 @ISA を上書きする機能は 5.8 での新機能です。 =item 3. =begin original The trust in item 2 is transitive. If A trusts B, and B trusts C, then A trusts C. So if you do not override C<@ISA> with C<@CARP_NOT>, then this trust relationship is identical to, "inherits from". =end original 第 2 規則における信頼は推移的です。 もし A が B を信頼し、B が C を信頼するならば、 A は C を信頼します。 よってもし C<@CARP_NOT> で C<@ISA> を上書きしなければ、この信頼関係は 「継承された」のと同じです。 =item 4. =begin original Any call from an internal Perl module is safe. (Nothing keeps user modules from marking themselves as internal to Perl, but this practice is discouraged.) =end original いかなる内部の Perl モジュールからの呼び出しも安全です。 (ユーザーモジュールに、Perl 内部のものであるとして自分自身を マークしないようにすることはできませんが、この慣習は非推奨です。) =item 5. =begin original Any call to Perl's warning system (eg Carp itself) is safe. (This rule is what keeps it from reporting the error at the point where you call C or C.) =end original Perl の警告システム (つまり Carp 自身) に対するどんな呼び出しも安全です。 (これは C や C を 呼び出した箇所のエラーを報告させないようにする規則です。) =item 6. =begin original C<$Carp::CarpLevel> can be set to skip a fixed number of additional call levels. Using this is not recommended because it is very difficult to get it to behave correctly. =end original 追加の呼び出しレベルの固定数を飛ばすために C<$Carp::CarpLevel> を 設定できます。 正しく振る舞うようにこれを設定するのはとても難しいので、これを使うことは 勧めません。 =back =head2 Forcing a Stack Trace (スタックトレースの強制) =begin original As a debugging aid, you can force Carp to treat a croak as a confess and a carp as a cluck across I modules. In other words, force a detailed stack trace to be given. This can be very helpful when trying to understand why, or from where, a warning or error is being generated. =end original デバッグを行う目的で、あなたは I<全ての> モジュールに渡って、 croak を confess として、carp を cluck として扱うよう Carp に 強制させることができます。 言い替えると、より詳細なスタックトレースを提供するよう強制します。 これはなぜ、あるいはどこから警告またはエラーが 生成されるのかを知ろうとする際、大きな助けとなり得ます。 =begin original This feature is enabled by 'importing' the non-existent symbol 'verbose'. You would typically enable it by saying =end original この機能は存在しないシンボル 'verbose' を 'import' することで 使用可能となります。 一般的には次のように宣言することで可能になります。 perl -MCarp=verbose script.pl =begin original or by including the string C<-MCarp=verbose> in the PERL5OPT environment variable. =end original あるいは環境変数 PERL50PT に C<-MCarp=verbose> を含めることでも 可能になります。 =begin original Alternately, you can set the global variable C<$Carp::Verbose> to true. See the C section below. =end original または、グローバル変数 C<$Carp::Verbose> を真に設定することもできます。 後述する C の節を参照してください。 =head1 GLOBAL VARIABLES (グローバル変数) =head2 $Carp::MaxEvalLen =begin original This variable determines how many characters of a string-eval are to be shown in the output. Use a value of C<0> to show all text. =end original この変数は、文字列 eval を何文字分出力に含めるかを決定します。 全てを表示するには C<0> を設定します。 =begin original Defaults to C<0>. =end original デフォルトは C<0> です。 =head2 $Carp::MaxArgLen =begin original This variable determines how many characters of each argument to a function to print. Use a value of C<0> to show the full length of the argument. =end original この変数は、関数のそれぞれの引数を何文字分表示するかを決定します。 引数を全て表示するには C<0> を設定します。 =begin original Defaults to C<64>. =end original デフォルトは C<64> です。 =head2 $Carp::MaxArgNums =begin original This variable determines how many arguments to each function to show. Use a value of C<0> to show all arguments to a function call. =end original この変数は、それぞれの関数でいくつの引数を表示するかを決定します。 関数呼び出しの全ての引数を表示するには C<0> を設定します。 =begin original Defaults to C<8>. =end original デフォルトは C<8> です。 =head2 $Carp::Verbose =begin original This variable makes C and C generate stack backtraces just like C and C. This is how C is implemented internally. =end original この変数は、C と C を、C や C と同様に スタックバックとレースを生成させるようにします。 これは C が内部で実装している方法です。 =begin original Defaults to C<0>. =end original デフォルトは C<0> です。 =head2 %Carp::Internal =begin original This says what packages are internal to Perl. C will never report an error as being from a line in a package that is internal to Perl. For example: =end original これは、どのパッケージが Perl 内部のものであるかを決定します。 C は、Perl 内部であるパッケージの中の行からのエラーを報告しません。 例えば: $Carp::Internal{ (__PACKAGE__) }++; # time passes... sub foo { ... or confess("whatever") }; =begin original would give a full stack backtrace starting from the first caller outside of __PACKAGE__. (Unless that package was also internal to Perl.) =end original これは、__PACKAGE__ の外側の最初の呼び出し元からの完全な スタックバックとレースを出力します。 (そのパッケージも Perl 内部のものでない限りです。) =head2 %Carp::CarpInternal =begin original This says which packages are internal to Perl's warning system. For generating a full stack backtrace this is the same as being internal to Perl, the stack backtrace will not start inside packages that are listed in C<%Carp::CarpInternal>. But it is slightly different for the summary message generated by C or C. There errors will not be reported on any lines that are calling packages in C<%Carp::CarpInternal>. =end original これは、どのパッケージが Perl の警告システムの内部かを決定します。 完全なスタックバックトーレスを生成するとき、これは Perl 内部と同様に 扱われ、スタックバックとレースは C<%Carp::CarpInternal> にある パッケージの内側からは開始されません。 しかし、C や C で生成される要約メッセージでは少し異なります。 これらのエラーは C<%Carp::CarpInternal> にある呼び出しパッケージの行は 報告されません。 =begin original For example C itself is listed in C<%Carp::CarpInternal>. Therefore the full stack backtrace from C will not start inside of C, and the short message from calling C is not placed on the line where C was called. =end original 例えば、C 自身は C<%Carp::CarpInternal> に入っています。 従って、C からの完全なスタックバックとレースは C の 内側からは開始せず、C を呼び出すことによる短いメッセージは C が呼び出された行は含みません。 =head2 $Carp::CarpLevel =begin original This variable determines how many additional call frames are to be skipped that would not otherwise be when reporting where an error occurred on a call to one of C's functions. It is fairly easy to count these call frames on calls that generate a full stack backtrace. However it is much harder to do this accounting for calls that generate a short message. Usually people skip too many call frames. If they are lucky they skip enough that C goes all of the way through the call stack, realizes that something is wrong, and then generates a full stack backtrace. If they are unlucky then the error is reported from somewhere misleading very high in the call stack. =end original この変数は、C の関数の一つへの呼び出しでどこでエラーを起きたかを 報告する際、いくつの追加の呼び出しフレームを飛ばすかを決定します。 完全なスタックバックとレースを生成する、これらの呼び出しの呼び出しフレームを 数えるのは比較的容易です。 しかし、短いメッセージを生成する呼び出しのためにこれを数えるのは 遙かに難しいです。 通常人々は呼び出しフレームを多く飛ばしすぎます。 もし幸運なら、C がコールスタック全体を通すのに十分なだけ飛ばして、 何かがおかしいことに気付き、完全なスタックバックとレースを生成します。 もし不運なら、エラーはコールスタックのとても誤解されやすいどこかから 報告されます。 =begin original Therefore it is best to avoid C<$Carp::CarpLevel>. Instead use C<@CARP_NOT>, C<%Carp::Internal> and C<%Carp::CarpInternal>. =end original 従って、C<$Carp::CarpLevel> を避けるのが最善です。 代わりに C<@CARP_NOT>, C<%Carp::Internal>, C<%Carp::CarpInternal> を 使ってください。 =begin original Defaults to C<0>. =end original デフォルトは C<0> です。 =head1 BUGS =begin original The Carp routines don't handle exception objects currently. If called with a first argument that is a reference, they simply call die() or warn(), as appropriate. =end original Carpルーチンは今のところexceptionオブジェクトをハンドルしていません。 もし最初の引数がリファレンスであれば、単純にdie()あるいはwarn()を 適切に呼び出します。 =begin meta Translate: 三浦真磁 Update: SHIRAKATA Kentaro (1.11) Status: completed =end meta