use warnings; use strict; /^([^,]+)/ && open F, ">>$1" and print F while <>; __END__