开发者

Perl chomp turn multiple digit number into 1 or 0

开发者 https://www.devze.com 2023-01-08 08:36 出处:网络
I have a situation where I need to read a file full of numbers in Perl. This work开发者_开发问答s fine in and of itself, but when I try to chomp each line it\'s turning the numbers that used to be 5 o

I have a situation where I need to read a file full of numbers in Perl. This work开发者_开发问答s 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.

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

$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. Instead you just want to say

chomp($line)
0

精彩评论

暂无评论...
验证码 换一张
取 消