in reply to Re^3: What does _ mean?
in thread What does _ mean?

Is -d obscure?

Replies are listed 'Best First'.
Re^5: What does _ mean?
by pileofrogs (Priest) on Feb 04, 2009 at 00:52 UTC

    How many places do you see '-d'? How many places do you see '_'? '-d' stands for directory. '_' stands for ??? -d is the same as the unix file test, '_' is the same as ???.

    It might be easy for you to remember things like this, bit it isn't for me. I guarantee you, in a week if you showed me -d(_) I'll have to look it up. And who wants to do that?

    Where is this code running? Is the performance that important? Is -d $filename so much slower?

    --Pileofrogs

      -d $FILE stands for "test to see if $FILE is a directory";

      _ stands for "the topic (of the current conversation)"*;

      so, -d _ means "test to see if the last tested file is a directory";

      *:

      $_ is the topic of the for, will be used by default by regexen and a lot of functions
      @_ is the collection of topics for a function (the arguments!)
      _ is the topic for file tests.
      []s, HTH, Massa (κς,πμ,πλ)

      How many places do you see '-d'?

      None.

      How many places do you see '_'?

      It should be used just about everywhere -d is used.

      -d is the same as the unix file test, '_' is the same as ???.

      I guess you'll be disappointed when you try to use _ with test.

        A google code search for '" -d " lang:perl' produces 108,000 results while a search for '"(_)" lang:perl' produces 6,000.

        I'll grant you, some of those -d results are spurious, someone documenting a '-d' command line switch and so on.

        Let's try and wrap this up. Do you agree with the statement, "-d $filename" is clearer than "-d (_)"? I'll agree that "-d (_)" is better for performance than "-d $filename". I'll even agree that my first post was stupid. OK?