Here’s an example for converting a string to have line breaks after every 3 characters. This would be useful for fixed length data…
$str =~ s/(…)/$1\n/g;
So if you had a string with the value aaabbbcccddd it would look like this…
aaa
bbb
ccc
ddd
The $1 references/matches whatever is in the parenthesis.