sub subNext { ... ## print some stuff my $print_=$_[0] print FILE $print_; ... $count=0; @data=(); next; } while ( some condition ){ ... ## some stuff (subNext breaks to the next instance of the loop) ... my @data; ## process to fill @data with data my @count; ## count increments in various places during the loop during the loop if ($some_var == 0){ &subNext($print); } ... ## rest of code ... }