http://www.perlmonks.org?node_id=94188


in reply to Seeking fixed length

There is more to comma-delimiting than meets the eye. See Text::xSV and DBD::CSV. But in general:
while( <> ){ split /,/; print pack 'A10'x (scalar @_), @_; }
Run it as perl convert.pl <input.txt >output.txt

See the docs for while, split and pack. You can accomplish similar things with sprintf (as pack stuff is pretty complicated if you're not used to perl). You might wanna check perldata and perlvar as well.

Hope this helps,

Jeroen
"We are not alone"(FZ)
Updated, typo fixed thanks particle.