Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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 ( [id://11120728]=note: print w/replies, xml ) Need Help??


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

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11120728]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-03-28 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found