ЭЛЕКТРОННАЯ БИБЛИОТЕКА КОАПП |
Сборники Художественной, Технической, Справочной, Английской, Нормативной, Исторической, и др. литературы. |
3.2.132 seekseek This function positions the file pointer for One interesting use for this function is to allow you to follow growing files, like this: for (;;) { while (<LOG>) { ... # Process file. } sleep 15; seek LOG,0,1; # Reset end-of-file error. } The final seek clears the end-of-file error without moving the pointer. If that doesn't work (depending on your C library's standard I/O implementation), then you may need something more like this: for (;;) { for ($curpos = tell FILE; $_ = <FILE>; $curpos = tell FILE) { # search for some stuff and put it into files } sleep $for_a_while; seek FILE, $curpos, 0; } Similar strategies could be used to remember the seek addresses of each line in an array. |