in reply to Remove whitespace in string and maintain overall length

Data records? Use pack.

my $field = pack "A37", ($foo =~ y/ //sr);