in reply to Rotating Log Files

In addition to tirwhan's most important remark, we also try to enforce the use of strict and warnings all the time, which your code doesn't: even if this is just a tiny snippet, it may contribute to spreading {bad, dangerous} programming techniques.

Also, using the ternary operator ?: just for his side effects is generally frowned upong, unless in golf or obfu, that is.

Last, even if this is to be considered only a portion of code and not a whole program, I think there's a typo in the glob: you probably mean $log_dir instead of log_dir.

Replies are listed 'Best First'.
Re^2: Rotating Log Files
by aukjan (Friar) on Dec 28, 2005 at 20:33 UTC
    Thanks to the remarks, I have added them to the snippit.. I always use strict and warnings, but left them out here since this is only a snippit

    Also, using the ternary operator ?: just for his side effects is generally frowned upong, unless in golf or obfu, that is.

    Which are the side-effects of this operator? I have never experienced any...

    Go Fish!

      Which are the side-effects of this operator? I have never experienced any...

      But... you're using them, nevertheless! Generally one should use if (and else) for flow control and ?: to operate on values, e.g.

      if (something) { do 'this'; } else { do 'that'; } do (something ? 'this' : 'that');

      Of course ?: also acts like an "if-then-else" and you can use it like that. But that's what is generally considered a side effect, since you're discarding its return value which its key feature.