in reply to string parsing
Don't chase your tail when you run into a problem like this. The weak link in our code is the assumptions we make. More often than not, after we have enough experience, we can rely on our assumptions because we've learned which ones are safe, which ones aren't, and which ones to question first when something goes wrong.
DATA is a special filehandle. I don't recall any documented warning against using it to open a regular file, but I don't think I'd assume that I could use it the way you're using it without running into a problem somewhere. When Perl has a special use for a word, I try not to use that word unless I want the Perl magic that comes with it.
This may seem simple and/or obvious, but you're making the assumption that your code is reading input, but I don't see any proof of that. I would suggest adding a print statement at the top of the while() loop so you can confirm the input:
print STDERR "bytes: ", length, "\n";
If the reported input length for each line is greater than zero, you can assume you have data to work with. If the print statement is never executed, you know that you're not reading input, I suspect this is the case. I would suggest that you use a different filehandle, test again, then look for misspellings, make sure your input file isn't zero length, etc.
Oh, and you are using warnings and strict, aren't you?
|
|---|