in reply to What does _ mean?

It means I've confused yet another generation of budding Perl programmers with a microoptimization that I called for back in the Perl 3 alpha days, and probably can be safely ignored now.

There are very few pieces of Perl that are uniquely mine. This is one of them. Sorry. :)

Replies are listed 'Best First'.
Re^2: What does _ mean?
by holli (Abbot) on Feb 04, 2009 at 16:24 UTC
    So how much more expensive is -e($file) && -f(_) than -e($file) && -f($file)?


    holli

    When you're up to your ass in alligators, it's difficult to remember that your original purpose was to drain the swamp.
      Four characters. Six, if you also rip out the parentheses. :-)

      Seriously, it's not just about saving one system call or half a dozen source code chars (altough I am all in favour of both) -- -d $filename && -x _ && -k _ && -u _ is simpler, cleaner, and more expressive than the alternative IMHO.

      BTW, I happen to like even more the perl6ish $filename ~~ :d & :x & :k & :u.

      []s, HTH, Massa (κς,πμ,πλ)
        In Perl 5.10, you can do
        -d -x -u $filename

      strace -tt -f -e '$file="filename";-e($file) && -f($file)'

      (as well as the alternative) says it's exactly one stat system call more expensive, unsurprisingly. Which on the system I tested it on was something like 0.0001 seconds but that will obviously vary.


      All dogma is stupid.