Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Need help understanding code snippet with "grep -f"

by Anonymous Monk
on Dec 23, 2015 at 02:59 UTC ( #1150990=note: print w/replies, xml ) Need Help??


in reply to Need help understanding code snippet with "grep -f"

My guess what this does is:

Don't guess, read the docs, grep is not like grep, grep is like foreach that filters out wanted list items

  • Comment on Re: Need help understanding code snippet with "grep -f"

Replies are listed 'Best First'.
Re^2:Need help understanding code snippet with "grep -f"
by fifaltra (Acolyte) on Dec 23, 2015 at 04:09 UTC
    Well, I did read it, but I couldn't figure out what the -f does there, and how the behaviour of grep described in the docs would give me a list of existing files. But that's probably cleared up now. Is there also documentation on this "-f" thing? Because it's really hard to google for something as short as "-f"...

      Reading this reminded me .. I had the exact same thing trip me up. -f is not a switch to the grep function but rather an independently defined function that just happens to be used as an argument here. But the unix-familiar mind sees that and thinks "grep -f" is a special form of "grep" and seeks the answer in the grep documentation. And doesn't find it.

      Using the block form of grep might have made this clearer.

      @files = grep { -f } glob("~/data/*");
      But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1150990]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2021-04-16 20:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?