in reply to A perverse use of grep

I don't so much object to the destructive grep as to the fact that it's using a substitution for what should be a negated pattern match:
my @lines = grep { s/^\s+//; s/\s+$//; length > 0 && !/^#/ } <$in>;
But this is all aesthetics anyway,

Replies are listed 'Best First'.
Re^2: A perverse use of grep
by brian_d_foy (Abbot) on Jun 15, 2005 at 03:04 UTC

    Your code fails to strip comments off lines it will keep, though. :)

    keep this part # part strip this part

    Update: That wasn't an intended feature. I guess I'm just too used to doing that since it's so easy to handle. :)

    --
    brian d foy <brian@stonehenge.com>
      True, but the "spec" for the OP didn't say that. It just said to ignore lines starting with # :)
      Yes, Errto is right, the super simple config file format specified for this project only supports comment lines where the first non-white space char is #.