in reply to convert a comma delimited file to a fixed length

I see many people suggesting a split and feeding the results through printf or sprintf to pad them to an appropriate length. While that works for the sample data above, I highly recommend using Text::CSV_XS to parse the comma-delimited file, because it will let you deal with more complex cases (and might actually be faster due to the XS code).

Also, while the printf family of functions works fine for this, isn't this particular application almost exactly what format and write were made for? Read perlform for more about using formatting to write out records.

<-radiant.matrix->
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law
  • Comment on Re: convert a comma delimited file to a fixed length