[英]Perl chomp turn multiple digit number into 1 or 0
I have a situation where I need to read a file full of numbers in Perl. 我有一种情况需要在Perl中读取一个充满数字的文件。 This works fine in and of itself, but when I try to chomp each line it's turning the numbers that used to be 5 or 6 digits into either 1 or 0. 这本身就可以正常工作,但是当我尝试选择每一行时,它将以前为5或6位的数字转换为1或0。
Ideas? 想法?
I need to chomp the numbers to assemble file paths with them, so the carriage returns are a problem. 我需要选择数字来组装它们的文件路径,因此回车是一个问题。
You're not using chomp
like 你不是喜欢chomp
$line = chomp($line)
are you? 你是? The return value of chomp
is the number of characters removed from the input, and not a chomped line of input. chomp
的返回值是从输入中删除的字符数,而不是输入的chomped行。 Instead you just want to say 相反,你只想说
chomp($line)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.