Re: peek next line in file
On Sep 27, 2007, at 1:29 AM, Mahurshi Akilla wrote:
Is there a way in perl to peek the next line in the file while keeping
the line pointer the same?
I want to do something like this:
while (<INFILE>)
{
//do some stuff
//?? peek next line ?? and enter conditional block//
//do some more stuff
}
You could do this:
my $pos = tell $fh;
my $next_line = <$fh>;
seek $fh, $pos, 0;
-- fxn
.
Relevant Pages
- Re: RM and abstract syntax trees
... implementation of the Persistent Object Store (POS). ... logical OIDs can outperform one with physical OIDs. ... consequences of shuffling data within the address space. ... Pointer swizzling refers to the mapping from OIDs to virtual memory ... (comp.databases.theory) - Re: Convert native character string to ASCII array of integers
... about-turn) in the space of three articles. ... pos points to the location of pc? ... to the pointer itself, in which case the code is totally screwed ... (comp.lang.c) - [RFC][PATCH] ps command race fix take 4 [3/4] callback subroutine
... proc_pid_readdir_callback moves pointer to the next task. ... * Find the first tgid to return to user space. ... return pos; ... (Linux-Kernel) - [RFC][PATCH] ps command race fix take 3 [3/4] proc_pid_readdir()
... uses watch_head, dual direction pointer. ... If a task which is pointed by file descriptor is removed, ... that pointer is moved to the next task ). ... return pos; ... (Linux-Kernel) - Re: Convert native character string to ASCII array of integers
... If we give the object which pos and pc both point to a name "obj", then the statement in question has three effects: ... I don't see any problem in all these effects occuring in the same expression. ... No object is written to and read from in the same expression except obj, and it is only read to determine the new value of obj, which is allowed. ... The pointer is incremented, not the pointee. ... (comp.lang.c) |
|