my @newlines = grep{/\S/}@lines; #move only lines that have #a non whitespace char to the left or @lines = grep{/\S/}@lines; #### while () # update: was: while (my $line = ) # don't really need "my line" here { next unless /\S/; #skip blank lines next if /^\s*#/; #skip comments, or whatever... blah, blah }