in reply to duplicate $_ while reading files; my compactness; code structure
1) Say I want to read a file which may have some lines commented out. I want one array with every line in it, whether it's commented out or not (and the '#' removed if it is), and one array with every line which isn't commented out in it, with any comments after the data being removed. This would be explained better like so:
my @lines = <DATA>; my @sans_hashes = map { /^#(.*)/s ? $1 : $_ } @lines; my @without_comment = grep !/^#/, @lines;
-- Randal L. Schwartz, Perl hacker
|
|---|