perl - 什么时候使用 chomp?

标签 perl chomp

就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the help center为指导。




9年前关闭。




chomp 函数的目的和优点是什么。
它都能做什么?
使用 chomp 会产生任何问题吗?
或者在文件打开后使用 chomp 是必要的?

最佳答案

chomp 用于删除 $/主要设置为 \n 的变量(新队)。

$/ is the input record separator, newline by default.

chomp: It returns the total number of characters removed from all its arguments. It's often used to remove the newline from the end of an input record.

关于perl - 什么时候使用 chomp?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12619545/

相关文章:

regex - $和Perl的全局正则表达式修饰符

ruby - 如果没有该特定行,我的代码将无法工作。为什么?

perl - Perl 中的 "Use of uninitialized value in scalar chomp"

ruby - 在Ruby中读取文件时如何删除换行符

Perl,延迟评估字符串

Perl Parallel::ForkManager 空返回

string - 检查字符串是否包含子字符串

perl - 为什么 '*' 在我的 .Rbuildignore 文件中不能作为 perl regexp?