in reply to Problem with SEEK to go back/forward a few lines.

I am guessing one of the reasons that you used seek and tell, is prpobably memory concern.

Still I suggest you to use Tie::File as Fletch already suggested. I read its entire source code before, and the author of that module actually used memory in a really wise way.

To use it, just do something like:
use Tie::File; my $self = tie @array, "Tie::File", "test.pl";

The first thing pop up in your mind might be whether the whole file would be loaded into that array (and I can see that you are only interested in a small piece of the file at any given moment). The answer is NO. The array size is not only well controlled, but also configurable.

Replies are listed 'Best First'.
Re: Re: Problem with SEEK to go back/forward a few lines.
by GaijinPunch (Pilgrim) on Oct 16, 2003 at 02:49 UTC
    Thanks for the info guys. It looks like Tie::File it is... I should really spend more time digging around CPAN.

    I've already started re-doing it, and it seems pretty nice.

    The file is relatively small -- no way could it consume a gig of memory.

    As for why I was using seek -- I just did a search on how to play with multiple lines, and that's what showed up.