How can I reset the “pointer” of a file to its start without reopening it? (Something like fseek in C?)
For example, I have a file that I want to grep for two patterns:
f=open('test') => #<File:test>
f.grep(/llo/) => ["Hello world\n"]
f.grep(/wo/) => []
Is it possible to reset f without reopening the file?
Note: I am not looking for workarounds; I can think some on my own ;).
Use rewind
Positions ios to the beginning of input, resetting lineno to zero.