Abhimanyu_Bhola wrote:
> Hi,
>
> While reading the contents of a file, on a particular match, I would like to
> start reading the file again from the line preceeding the match. (say, the
> match occured at line #45, I would like to start the file reading from line
> #44)
>
> #1 I thought of making a copy of the filehandle(via & argument in open
> function) but that also doesn't solve the purpose as both of them always
> point to the same location.Am I missing something here?
> #2 Other option would be to open a secondary handle to the same file and
> keep it one line before the main handle but his would mean an overhead of
> managing an extra handle.
>
> Any other way to achieve this?
> or
> Is option #2 the way to do it?
1) You could save the prior line each time before you read the next line.
2) You can use tell and seek to determine and set your file position.
See perlfunc manpage.
--
,-/- __ _ _ $Bill Luebkert ICQ=14439852
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs