in reply to Re: Re: Files! Reading specific parts
in thread Files! Reading specific parts
Ah, OK. First you're getting the size of the file with the -s test. Then you're reading in the entire file with read---now the file position is at the very end of the file. Now, when you say "seek back 1700 characters from the current position", you're saying 1700 characters from the end of the file, since the file position is at the end of the file.
I think you want to use the pos function, which will tell you where in the string the last match happened. Since you've read the entire file, the positions in the string will be equal to the positions in the file, so you can just seek to the position that pos returns.
As others have suggested, though, you should consider using an HTML parser. HTML parsing is hard, and other people have already done it.
|
|---|