DelphiFAQ Home Search:
General :: Programming :: perl
General questions about perl.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

Trim blank space at the beginning and end of a string

Question:

How do I strip blank space from the beginning/end of a string? In other language this is usually called Trim().

Answer:

The best solution is doing it in two steps (faster than the typical first attempt to do it with one statement.

$string =~ s/^\s+//;
 $string =~ s/\s+$//;  

Generated 12:01:52 on Dec 11, 2017