while () { chomp; s/^\s*#.*//; # remove comment-only lines next if /^$/; # skip blank lines (or, commented out lines) do_something_with($_); }