in reply to Breaking output lines into N-element chunks

I would do it like this:
while (@vars) { print "directive: "; print join " ", map munge_var($_), splice @vars, 0, 4; print $/; }

Update: if I were feeling crazy, I might instead do it like this:

sub print_directive { return unless @_; print "directive: "; print join " ", map munge_var($_), splice @_, 0, 4; print $/; &print_directive; } print_directive @vars;