http://www.perlmonks.org?node_id=1017578


in reply to how can i increase the size of a record in a file

The output string you shared has a length of 212, which is 40 fewer than the record size of 252--and you have exactly 40 empty fields, i.e., ||, in that string. If you filled each empty field with a character, e.g., an "X", you'd have a 252-byte record. Is this what you want to do? Since the records are | delimited, why does each record need to be 252 bytes?

If you do want to fill all the empty fields with an "X" (or some other character) you can do the following with the string:

$string =~ s/(?<=\|)(?=\|)/X/g;

However, it would be far better to address the data in your variables before creating that string.

My apologies if I've misunderstood your problem.

Update I: Athanasius makes an excellent point about the "|" character; I merely assumed it was the field delimiter.

Update II: Eliminating elements in your original posting makes your issue(s) a moving target and nullifies some responses; e.g., you've removed the record-size 'problem.' Nevertheless, your reformatting evidences a newline in one of your variables, and by the break in your output string, you should be able to tell which variable and then remove the newline.