1 => [ [50, 26, "Ins Company Name" , ""]], 2 => [ [50, 26, "Ins Street Address" , ""]], 3 => [ [50, 26, "Ins Street Address 2", ""]], 4 => [ [50, 12, "Ins City" ,""], [64, 2, "Ins State",""], [67, 5, "Ins Zip" ,""], ], 6 => [ [57, 22, "Unknown", ""]], 8 => [ [ 1, 1, "Medicare" ,"" , '1'], [ 8, 1, "Medicade" ,"" , '1'], [15, 1, "Champus" ,"" , '1'], [24, 1, "Champva" ,"" , '1'], [31, 1, "Group Health Plan" ,"" , '1'], [39, 1, "FECA BLK LUNG" ,"" , '1'], [45, 1, "Other" ,"" , '1'], [50, 17, "Insured's I.D. Number" ,"" , '1a'], ], #### my $hcfa = do "hcfa.lay"; my $layout = []; foreach my $line ( sort keys %$hcfa ) { foreach my $item ( @{$hcfa->{$line}} ) { insert_into_layout($layout, $line, $item->[0], "X" x $item->[1]); } } print layout_form($layout); sub insert_into_layout { my ($layout, $line, $row, $value) = @_; my @data = split //, $value; my $offset = 0; foreach ( @data ) { $layout->[$line][$row + $offset++] = $_; } } sub layout_form { my $layout = shift; my $output; foreach my $row (@$layout) { foreach my $val (@$row) { $output .= (defined $val ? $val : ' '); } $output .= "\n"; } return $output; }