in reply to Closing program when end of files is reached

I sometimes short circuit while or for loops with something like:

while (<FILE>) { chomp; s/^\s*#.*//; # remove comment-only lines next if /^$/; # skip blank lines (or, commented out lines) do_something_with($_); }
This turns comment-only lines into blank lines, and then skips any blank lines in the file (not just the last line of the file).

Is this what you're looking for?

Alan