There’s always a better way in perl. Like methods to string unwanted whitespace from the beginning or end of strings.
Here are two examples – both using 2 lines of code. Which do you find more readable/maintainable?
$str =~ s/^\s+//; $str =~ s/\s+$//;
use String::Util 'trim'; $str = trim($str);
Contributed by my good friend and colleague, gregor42.