in reply to Re: Assign Contains RegEx WTF??
in thread Assign Contains RegEx WTF??

It looks like needlessly terse code to me even though it probably works great.
I've seen enough code by enough people doing this, that's it's idiom to me.

But then, most idiom will look like needlessly terse code to beginners.

Replies are listed 'Best First'.
Re^3: Assign Contains RegEx WTF??
by davido (Cardinal) on May 20, 2009 at 08:27 UTC

    How does the quote go? "Any sufficiently advanced technology is indistinguishable from magic." (Or something along those lines.)

    Anyway, if the point is to write maintainable code, it still seems reasonable to document well enough that the intent is clear. Code comments aren't only for beginners. They also serve to illustrate to future maintainers that "you really did mean to do that." Plus, they will help to save time as someone else familiarizes him/herself with your code. Or is that "h(?:im|er)self"? ;)


    Dave

      Yes, but where do you stop? At the end of that road is:
      $i++; # Add 1 to $i
      IMO, if you have to document the syntax, you should rewrite the code. Now, I don't think:
      ($copy = $orig) =~ s/PATTERN/REPLACEMENT/;
      is obscure. It shouldn't need comments. If you feel you're among novices or bad programmers, still don't comment the code. Rewrite it in baby steps.