in reply to A perverse use of grep
Are you paying for your whitespace or something??my @lines; { local $_; while ( <$in> ) { # Remove leading and trailing whitespace s/^\s+//; s/\s+$//; # Remove comments from the first # to the end of the line s/#.*//; push @lines, $_ if length $_; } }
Update: Fixed bug as per brian_d_foy's comment.
Update: Changed per demerphq's comment.
Update: Added bare-block to localize $_ per itub's comment. I don't think this is completely necessary, but it's good to be anal.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A perverse use of grep
by brian_d_foy (Abbot) on Jun 15, 2005 at 03:05 UTC | |
|
Re^2: A perverse use of grep
by eyepopslikeamosquito (Archbishop) on Jun 15, 2005 at 03:16 UTC | |
|
Re^2: A perverse use of grep
by demerphq (Chancellor) on Jun 15, 2005 at 09:44 UTC | |
by itub (Priest) on Jun 15, 2005 at 17:20 UTC | |
by dragonchild (Archbishop) on Jun 15, 2005 at 12:01 UTC |