my @newlines = grep{/\S/}@lines; #move only lines that have #a non whitespace char to the left or @lines = grep{/\S/}@lines;