perl-5.38.0
length EXPR
length

Returns the length in characters of the value of EXPR. If EXPR is omitted, returns the length of $_. If EXPR is undefined, returns undef.

EXPR の値の 文字 の長さを返します。 EXPR が省略されたときには、$_ の長さを返します。 EXPR が未定義値の場合、undef を返します。

This function cannot be used on an entire array or hash to find out how many elements these have. For that, use scalar @array and scalar keys %hash, respectively.

この関数は配列やハッシュ全体に対してどれだけの要素を含んでいるかを 調べるためには使えません。 そのような用途には、それぞれ scalar @arrayscalar keys %hash を 利用してください。

Like all Perl character operations, length normally deals in logical characters, not physical bytes. For how many bytes a string encoded as UTF-8 would take up, use length(Encode::encode('UTF-8', EXPR)) (you'll have to use Encode first). See Encode and perlunicode.

全ての Perl の文字操作と同様、length は通常物理的な バイトではなく論理文字を扱います。 UTF-8 でエンコードされた文字列が何バイトかを知るには、 length(Encode::encode('UTF-8', EXPR)) を使ってください (先に use Encode する必要があります)。 Encodeperlunicode を参照してください。