What all solutions above at least implicitly discussed
was the need to preserve $/ for the next round in the
outer while{} loop. That's why all solutions
use at least one local statement to keep
the old value of $/.
You should take some time to study the solutions and
next time maybe be more explicit at what dosen't work
with your program, as the program works almost well
(except for one warning on undefinded data). I guess
a more representative dataset would have been
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXaaaa
abcdefghijklm%nopqrstuvw%xyz
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXaaaa
abcdefghijklm%nopqrstuvw%xyz
which dosen't work that well with your original program.
|