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

easily re-implemented in Perl. It seems ...

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

  • Comment on Re^3: How to trim a line from leading and trailing blanks without using regex or non-standard modules
  • Download Code

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
      Not quite, there is no optional parameter to provide the "white" character class.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

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

    I was pretty sure that you would answer and provide a solution 😎 Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help