in reply to How to remove a carriage return (\r\n)
no matter which platform I am on. A real trick is trying to find blank lines in a slab of (multiline) text:sub remove_trailing_newline { $_[0] =~ s/[\r\n]+\Z//; }
if ( m/(\r\n|\n\r|\r|\n)$1/ ) { # two newlines in a row! }
Update: Thanks to rev_1318 for pointing out that the $1 need be replaced with \1 in the regexp.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to remove a carriage return (\r\n)
by rev_1318 (Chaplain) on Nov 02, 2005 at 12:45 UTC |