in reply to TRIM in Perl?
I have a problem with that one:
#!/usr/bin/env perl use strict; use warnings; my @strings = (' Test ', 'Test 2 ', ' A ', 'multi line string ',' '); foreach my $string (@strings) { $string =~ s/^\s+//m; $string =~ s/\s+$//m; print "'$string'\n"; }
Returns:
That is almost correct, but it does remove a line break in the middle of the string it shouldn't: There should be two line breaks between "multi" and "line" but only one remains.'Test' 'Test 2' 'A' 'multi line string' ''
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: TRIM in Perl?
by Corion (Patriarch) on Jan 12, 2011 at 10:43 UTC | |
|
Re^2: TRIM in Perl?
by Anonymous Monk on Jan 12, 2011 at 10:42 UTC | |
|
Re^2: TRIM in Perl?
by Anonymous Monk on Feb 10, 2011 at 10:01 UTC |