- evalbytes EXPR
- evalbytes
-
This function is similar to a string eval, except it always parses its argument (or
$_
if EXPR is omitted) as a string of independent bytes.この関数は 文字列 eval に似ていますが、引数(EXPR が 省略された場合は
$_
) を常にバイト単位のの文字列として 扱います。If called when
use utf8
is in effect, the string will be assumed to be encoded in UTF-8, andevalbytes
will make a temporary copy to work from, downgraded to non-UTF-8. If this is not possible (because one or more characters in it require UTF-8), theevalbytes
will fail with the error stored in$@
.use utf8
が有効のときに呼び出されると、 文字列は UTF-8 でエンコードされていると仮定され、evalbytes
は、非 UTF-8 にダウングレードした一時的なコピーを作ります。 (UTF-8 が必要な文字があるために) これが不可能な場合、evalbytes
は失敗し、エラーは$@
に保管されます。Bytes that correspond to ASCII-range code points will have their normal meanings for operators in the string. The treatment of the other bytes depends on if the
'unicode_strings"
feature is in effect.ASCII の範囲の符号位置に対応するバイトは、 文字列の操作に関して通常の意味を持ちます。 その他のバイトの扱いは、 <
'unicode_strings"
feature|feature/'unicode_strings' 機能> が有効の場合か どうかに依存します。Of course, variables that are UTF-8 and are referred to in the string retain that:
もちろん、UTF-8 で文字列の中で参照されている変数はそのままです:
my $a = "\x{100}"; evalbytes 'print ord $a, "\n"';
prints
というのは、次を表示し、
256
and
$@
is empty.$@
は空になります。Source filters activated within the evaluated code apply to the code itself.
eval されたコード内で有効になったソースフィルタはコード自体に適用されます。
evalbytes
is available starting in Perl v5.16. To access it, you must sayCORE::evalbytes
, but you can omit theCORE::
if the"evalbytes"
feature is enabled. This is enabled automatically with ause v5.16
(or higher) declaration in the current scope.evalbytes
は Perl v5.16 から利用可能です。 これにアクセスするにはCORE::evalbytes
とする必要がありますが、"evalbytes"
機能 が 有効ならCORE::
を省略できます。 これは現在のスコープでuse v5.16
(またはそれ以上) 宣言があると 自動的に有効になります。