in reply to how to find the length of any line of file

Can you show us three lines of input and show us the output you get, and why you think it is not correct?

It helps us to give you advice that is more to the point if you show us the input and output, and tell us why you think it's not correct.

Also, maybe consider explaining what the following part of your code is supposed to do:

if ($.=<>){ print length "$line"; }

Good general advice would be to allow Perl to tell you about problematic parts in your program. The warnings pragma enables that. Add the following line to the top of your program (before the open line):

use warnings;

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.