in reply to Re: 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

You won

«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

  • Comment on Re^2: 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^3: How to trim a line from leading and trailing blanks without using regex or non-standard modules
by LanX (Saint) on Aug 14, 2020 at 14:43 UTC
    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

        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

      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