PYPL
PYPL

Reputation: 1849

Finding line number

How can I find the current position in a file? I just can count total numbers in a file. I've read about functions tell() and seek() but I don't understand how exactly to use them.

Upvotes: 1

Views: 266

Answers (1)

Lee Duhem
Lee Duhem

Reputation: 15121

When you are reading from a file (filehandle, actually), you can use $. to find out the line number of current input line. To reset the value of $., you need to close the current input filehandle.

See perlvar.

Upvotes: 1

Related Questions