Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl chomp turn multiple digit number into 1 or 0

Tags:

perl

I have a situation where I need to read a file full of numbers in 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.

Ideas?

I need to chomp the numbers to assemble file paths with them, so the carriage returns are a problem.

like image 243
chuck taylor Avatar asked Dec 09 '22 14:12

chuck taylor


1 Answers

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)
like image 160
mob Avatar answered Dec 15 '22 01:12

mob