what happens after the eof is reached with <> operator in perl?
I’m reading INP1 line by line with
while(<INP1>) {
}
but I need to do this reading multiple times and I need to start from the beginning of the file each time. How can I do that? Is there something like refreshing the stream in perl?
Thanks in advance.
If
INP1is connected to a regular filehandle (not a socket handle or pipe handle), you can alsoseekback to the beginning of the file.Another option is to load the entire file into an array one time, and then loop through that array as often as you wish. This is a good idea if the whole file fits comfortably in memory and if the contents of the file won’t change between traversals.