binmode $fh_out; while (length($str)) { my $rec = substr($str, 0, 90, ''); print $fh_out "$rec\x0D\x0A"; }