Using
s/// for this is actually pretty straight forward and readable.
I'd reconsider your
seek() though. Consider that if you don't have any newlines in your file, your code reads the whole file after one iteration of your
for (<in>) loop. So, just use it... there's no need to reread the file. Something like:
$_ = <IN>;
unless (tr/\n//) {
s/(.{320})/$1\n/g;
}
print OUT;
-sauoq
"My two cents aren't worth a dime."