How do I strip blank space from the beginning/end of a string? (contributed by brian d foy) A substitution can do this for you. For a single line, you want to replace all the leading or trailing whitespace with nothing. You can do that with a pair of substitutions. s/^\s+//; s/\s+$//;