perldoc -f seek 

/Stefan Lidman

Paul Kraus wrote:
> 
> How do I look up info for a fuction like seek. I tried perldoc seek and
> perldoc Seek to no avail.
> 
> Thanks.
> 
> > -----Original Message-----
> > From: Bob Showalter [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, December 05, 2002 2:14 PM
> > To: 'Paul Kraus'; Perl
> > Subject: RE: Snagging the last page of a report
> >
> >
> > > -----Original Message-----
> > > From: Paul Kraus [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, December 05, 2002 2:00 PM
> > > To: Perl
> > > Subject: Snagging the last page of a report
> > >
> > >
> > > Every month I have several reports I print to disk. They are
> > > hundreds of
> > > pages long. I only need the last page of each. As it is now I
> > > open it in
> > > a text editor scroll down and copy the last page to a new
> > > text document.
> > > This is irritating and I want to play with the Perl I have been
> > > learning.
> > >
> > > How can I snag the last page of something.
> > >
> > > I could do a search to find end of file (I think you can do
> > that with
> > > reg expr).
> >
> > No, regexes are for searching strings. The seek() function
> > can be used to position the pointer at the end of the file.
> >
> > > Then if somehow I could have it report the position of the file the
> > > EOF occurs I could then somehow count back to the first part of
> > > the page then ummm well you see my confusion. Any help and
> > suggestions
> > > are appreciated. All though a solution would definitely solve
> > > my problem
> > > it wouldn't be fun at all :)
> >
> > The trick is to find whatever delimits the last page. It
> > might be as simple as an ASCII formfeed (12) character.
> >
> > In general, you would seek to EOF, then back up a
> > "reasonable" page size (say 2kb) and read a block of data. If
> > you find the start of the last page, you're good. If not,
> > back up another 2k and try again.
> >
> > >
> > > However if I could get some hints or be pointed at some
> > > relevant info I
> > > would greatly appreciate it. Thanks in advance.
> >
> > There's a File::ReadBackwards module on CPAN that might be
> > helpful. It handles all the file pointer manipulation for
> > you. You could just read lines backwards into an array until
> > you find the first line of the page. Then print
> > reverse(@myarray) to print the last page.
> >
> > If the files were small, you could suck the whole file into a
> > single string and extract the last page using a regex. But
> > for big reports that's a bad idea...
> >
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to