while ( ) { # ... print header unless $already_printed_header++; # ... }