in reply to Need help understanding code snippet with "grep -f"
The -f is a file operator that returns true if the file (by default given in $_) exists so the grep is testing to see if named files exist and dropping any that don't exist out of the list.
grep can use either grep {...} @list or grep ..., @list syntax. You are using the second variant.
grep {-f} map {...} @list;
might be clearer.
Update: Oh, and to "find all the files" you need something like glob:
my @files = grep {-f} map {glob "$_/*vp.o$id"} qw/ archiv/;
Although if you are using glob the grep is probably redundant.
Premature optimization is the root of all job security
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Need help understanding code snippet with "grep -f"
by Marshall (Canon) on Dec 23, 2015 at 07:48 UTC | |
by afoken (Chancellor) on Dec 23, 2015 at 09:20 UTC | |
by Marshall (Canon) on Dec 23, 2015 at 09:49 UTC | |
by GrandFather (Saint) on Dec 23, 2015 at 08:47 UTC | |
by Marshall (Canon) on Dec 23, 2015 at 09:28 UTC | |
Re^2: Need help understanding code snippet with "grep -f"
by fifaltra (Acolyte) on Dec 23, 2015 at 04:16 UTC |
In Section
Seekers of Perl Wisdom