in reply to How to process variable length fields in delimited file.

You can create an unpack template that parses each line, the only problem is that in order to use the length fields, they must be separated by null bytes, not zeroes. But it's easy to change spaces to nulls and then back:

#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use Syntax::Construct qw{ /r }; my $template = join 'x', 'A9', # ssn 'A5', # employee number 'Z*/A', # employee name 'A8', # hire date 'Z*/A', # address 'A2', # state 'Z*/A', # city 'A5', # zip ; while (<>) { say join ',', map tr/\x0/ /r, unpack $template, tr/ /\x0/r; }

Update: used tr instead of s .

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,