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