in reply to Re^2: How to trim a line from leading and trailing blanks without using regex or non-standard modules
in thread How to trim a line from leading and trailing blanks without using regex or non-standard modules
DB<33> sub trim { $_[1] //= qr/\s/; $_[0] =~ s/^[$_[1]]+|[$_[1]]+$// +g } DB<34> $a = $b = " \n . aaa . \n " DB<35> trim $a DB<36> trim $b, " " DB<37> x $a,$b 0 '. aaa .' 1 ' . aaa . ' DB<38>
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: How to trim a line from leading and trailing blanks without using regex or non-standard modules
by marto (Cardinal) on Aug 14, 2020 at 15:13 UTC | |
by LanX (Saint) on Aug 14, 2020 at 16:06 UTC | |
Re^4: How to trim a line from leading and trailing blanks without using regex or non-standard modules
by karlgoethebier (Abbot) on Aug 14, 2020 at 17:12 UTC |