my $state = 0; foreach my $line (){ if($state){ # do whatever you need with the "next" line $state = 0; } else { # do what you normally do if($next_line_needed){ $state = 1; } } }