in reply to Re: Pattern Matching With Regular Expressions
in thread Pattern Matching With Regular Expressions

Sometimes we forget that perl doesn't actually have a function called "rewind" -- but it does have a function called seek, which achieves the same result. The issue is that a normal file handle maintains a "pointer" to the next position to be read (i.e. the end-point of the data that was last read). When you get to the end of the file, this pointer is at EOF, which means nothing else can be read.

The "seek" function (perldoc -f seek) can reposition the pointer to any position in the file; a typical place to go is back to the beginning:

seek FILE, 0, 0; # position file pointer at start of file