perl-5.38.0
chop VARIABLE
chop( LIST )
chop

Chops off the last character of a string and returns the character chopped. It is much more efficient than s/.$//s because it neither scans nor copies the string. If VARIABLE is omitted, chops $_. If VARIABLE is a hash, it chops the hash's values, but not its keys, resetting the each iterator in the process.

文字列の最後の文字を切り捨てて、その切り取った文字を返します。 文字列の検索もコピーも行ないませんので s/.$//s よりも、ずっと効率的です。 VARIABLE が省略されると、$_ を対象として chop します。 VARIABLE がハッシュの場合、ハッシュのキーではなく値について chop し、 このプロセスの each 反復子をリセットします。

You can actually chop anything that's an lvalue, including an assignment.

実際のところ、代入を含む左辺値となりうるなんでも chop できます。

If you chop a list, each element is chopped. Only the value of the last chop is returned.

リストを chop すると、個々の要素が chop されます。 最後の chop の値だけが返されます。

Note that chop returns the last character. To return all but the last character, use substr($string, 0, -1).

chop は最後の文字を返すことに注意してください。 最後以外の全ての文字を返すためには、substr($string, 0, -1) を 使ってください。

See also chomp.

chomp も参照してください。