Next | Program Repair Shop | 294 |
Better is if we can get the split right on the first try
@lines = split /\n(?!\s)/, $header;
\s means "A space character"
(?!\s) means "Peek ahead to see if the next character is not a space"
This split discards only the newlines that are not followed by whitespace
If you want, you can then remove the remaining newlines:
for (@lines) { s/\n\s+/ /g }
7 lines become 2 (or 1)
Next | Copyright © 2002 M. J. Dominus |