From 8d4bf1abd90c1ce226872bd2a7a5fe5e9423d35e Mon Sep 17 00:00:00 2001 From: eleksir Date: Sun, 3 Apr 2022 16:36:56 +0300 Subject: [PATCH] Use utf8-friendly space symbols chop operation in trim() --- lib/BotLib/Util.pm | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/BotLib/Util.pm b/lib/BotLib/Util.pm index 0ae39fe..f116a12 100644 --- a/lib/BotLib/Util.pm +++ b/lib/BotLib/Util.pm @@ -23,13 +23,8 @@ sub trim { return $str; } - while (substr ($str, 0, 1) =~ /^\s$/xms) { - $str = substr $str, 1; - } - - while (substr ($str, -1, 1) =~ /^\s$/xms) { - chop $str; - } + $str =~ s/^\s+//; + $str =~ s/\s+$//; return $str; }