Perl: trimErroneousCharactersAtEnds