in reply to removing \n with for each
Why bother extracting columns from a CSV file yourself when people have done it before? See Text::CSV_XS and its incredibly long list of relations.