print map { chomp; $_ . /^TITLE/? "\n" : ' '; } grep { /$re/ } ; #### { local $" = ' '; # just making sure - this is the default print "@{[grep {/$re/} ]}"; }