my @strs = (' this', ' is', ' a ', ' list '); s/^\s+|\s+$//g for @strs; print "@strs\n"; __output__ this is a list