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.
|
|---|