in reply to Re^2: Grep Array Multiple times
in thread Grep Array Multiple times
It is also possible to combine all this into a single map although I don't think that I'd do it in this case because it reads to me as less clear...this is just an example of "how" should the desire arise... The important part here is the return value. Returning () from a map is different than returning undef. Undef is a value. () means "nothing is returned".
I guess as a side point, I like lining up logical conditions because human beings are "programmed" by instinct to process information better from top to bottom better than left to right and certainly better than diagonally. So when things don't fit nicely on one printed line, I do it like below.
my @files2 = grep { $_ ne "file1" and $_ ne "file2" and -f "$dir2/$_" }map { lc }readdir(DIR2); my @files = map { lc; ( $_ ne "file1" and $_ ne "file2" and -f "$dir2/$_" ) ? $_ :() }readdir(DIR2);
|
|---|