Since the fields never change length it would seem that unpack is a better choice than substr, is that correct?
Perhaps. Read
perlpacktut, which compares the various approaches. Here is an example of using
unpack to parse each line into an array:
use warnings;
use strict;
while (<DATA>) {
chomp;
my @cols = unpack 'A1A15A14A16', $_;
print join(',', @cols), "\n";
}
__DATA__
C4432882490H019000020150211ESL6690 0H2015PC
C4833076550HC0P0000201412093J46651 0H2015DX
C6033106980H057130020150323FRE7602 0H2015PC
C663160140MT007015G20141124274847A MT2015PC