in reply to How to 'peek' at next line while parsing with <>

here's a buffered method:

#!/usr/bin/perl use strict; use warnings; { $_ = <DATA>; my $next_line; while( $next_line = <DATA> ) { print "current line: $_ -- next line: $next_line$/"; } continue { $_ = $next_line; } } __DATA__ 1 2 3 4 5
yeilds:

current line: 1 -- next line: 2 current line: 2 -- next line: 3 current line: 3 -- next line: 4 current line: 4 -- next line: 5
note: the last line is not processed.

~Particle *accelerates*