in reply to What does _ mean?

I think it means you might want to smack the writer of said code up the head and give them a copy of the PBP book.

Update:

Heh... As I read it, the whole book was about writing clear code. "Don't use $_" etc... (Yes, my statement in support of clarity was totally unclear... sigh...)

Replies are listed 'Best First'.
Re^2: What does _ mean?
by runrig (Abbot) on Feb 02, 2009 at 20:26 UTC
    And what does PBP say? To make unnecessary calls to stat (I hope not)?
      I looked up '_' in PBP's index and it referred me to (underscore). Looked up 'underscore', subtopic 'best practice' : p.473:

      Use underscores to improve the readability of long numbers.

      No reference to the file operations in any of the other subtopics in the index either.


      This signature will be ready by Easter
        The index mentions stat. But like underscore, there's no relation to the topic at hand.

      It doesn't specifically address this, but I'd apply the general principle of commenting any obscure usage. Of course, one man's obscure is another man's clear.

      I ran into this exact thing in an old program I had to modify and added this comment after figuring out what it meant:

      ######### FINALLY FIGURED OUT WHAT _ IS!!! # QUOTE: # # If any of the file tests (or either the stat() or lstat() operators +) are given # the special filehandle consisting of a solitary underline, then the +stat structure # of the previous file test (or stat operator) is used, saving a syste +m call. # # Isn't that something? All I gotta do now figure out what or where i +s the previous # test??
Re^2: What does _ mean?
by ikegami (Patriarch) on Feb 03, 2009 at 19:51 UTC

    the whole book was about writing clear code.

    How is "_" unclear? It has one very specific use.

      How about obscure?

        Is -d obscure?

        • It's documented in the same place as -d.
        • It's only used by -d and siblings.
        • And it should be used just about everywhere -d is needed.
Re^2: What does _ mean?
by bichonfrise74 (Vicar) on Feb 03, 2009 at 01:57 UTC
    What would be the "best practice" in this case? How would this be re-written?
      pileofrogs is probably confusing the "_" file test operation argument with implicit usage of the "$_" variable, which is discouraged by some. "_" used appropriately as a file test argument is fine.