use warnings; use strict; my @fields; my $fieldValue = 'Grand'; # Given name field contents push @fields, [$fieldValue, 10]; # 20 character wide field $fieldValue = 'Father'; # Sir name push @fields, [$fieldValue, 10]; # 25 character wide field push @fields, ['007 Bond Street', 15]; push @fields, ['Wibble Wobble', 15]; push @fields, ['', 15]; push @fields, ['Erewhon', 15]; #... my $record = join '', map {sprintf "%-*.*s", $_->[1], $_->[1], $_->[0]} @fields; print $record; #### Grand Father 007 Bond StreetWibble Wobble Erewhon