while ($line = <>) { # redo comes HERE # do something my $next = <>; if ($next !~ /^#/) { # if the next line DOES NOT start with a "#" # reuse it and restart this iteration of the loop $line = $next; redo; } } #### while ($line = <>) { # ... my $pos = tell ARGV; my $next = <>; seek ARGV, $pos, 0; # ... }