in reply to Shell scripts?

To the second question, your while loop's $count will depend on the value of $/. That is what perl looks for to determine that a "line" has been read.

For many binary file types, there is no meaningful notion of a "line". For graphics files, the number of pixel rows might serve, but that must be deduced from information in the file header. Image::Size will help with that.

The short answer is no, there is no universal line marker for all file types.

For text files, your idea is fine so long as $/ is correctly set.

After Compline,
Zaxo