ultranerds has asked for the wisdom of the Perl Monks concerning the following question:
This outputs:# my @split = split /\n|\r/, $message; my @split = split /[\n\r]/, $message; foreach (@split) { $_ =~ s/^[\n\r]//sig; $_ =~ s/[\n\r]$//sig; print "BLA ... \"$_\" <br />"; }
I just can't work out why its putting a extra newline breaks, where there shouldn't be (I want one line of data per line, and that it)BLA ... "== another main header" BLA ... " " BLA ... " " BLA ... " dfgdfg" BLA ... " " BLA ... " === a sub header" BLA ... " dfgdfg" BLA ... " " BLA ... " === another new sub header" BLA ... " " BLA ... " sdfsdf" BLA ... " " BLA ... " ==== a sub-sub header" BLA ... " g" BLA ... " dsfgdsf" BLA ... " The actual code being passed in (via a textarea box), is: == another main header dfgdfg === a sub header dfgdfg === another new sub header sdfsdf ==== a sub-sub header g dsfgdsf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Doing a split// but not working
by JavaFan (Canon) on Jan 05, 2010 at 13:10 UTC | |
by ultranerds (Hermit) on Jan 05, 2010 at 13:21 UTC |