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 ... } #### sub subNext { ... ## print some stuff $print_=$_[0] print FILE $print_; ... print "count is: $$_[2] , reference is: $_[2] \n"; print "data is: @$_[1] , reference is: $_[1] \n"; $_[2]=0; $_[1]=(); 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 if ($some_var == 0){ &subNext($print, \@data, \$count); } ... ## rest of code ... }