in reply to (dont want) split to autoremove "\n"'s
Hello endurocross, and welcome to the Monastery!
Just change the pattern on which you are splitting. For example:
22:59 >perl -MData::Dump -wE "my $s = qq[\n</body> \n</html>]; my @arr +ay = split(/[ \t]+/, $s); dd \@array;" ["\n</body>", "\n</html>"] 23:00 >
Update 1: From the documentation for split:
As another special case, split emulates the default behavior of the command line tool awk when the PATTERN is either omitted or a literal string composed of a single space character (such as ' ' or "\x20", but not e.g. / /). In this case, any leading whitespace in EXPR is removed before splitting occurs, and the PATTERN is instead treated as if it were /\s+/; in particular, this means that any contiguous whitespace (not just a single space character) is used as a separator. However, this special treatment can be avoided by specifying the pattern / / instead of the string " ", thereby allowing only a single space character to be a separator.
Update 2: Changed /[ \t]/ to /[ \t]+/.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|