in reply to Re: Scalar assignment with loop iterator considered bad?
in thread Scalar assignment with loop iterator considered bad?

Your code doesn't do the same thing. It leaves out the last comma.
  • Comment on Re^2: Scalar assignment with loop iterator considered bad?

Replies are listed 'Best First'.
Re^3: Scalar assignment with loop iterator considered bad?
by BrowserUk (Patriarch) on Jul 22, 2005 at 19:04 UTC

    Fair enough

    $var = join( ', ', @columns ) . ', ';

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

      Of course, we still have an extra comma-space if @columns is empty...

      Arg. Sorry, couldn't resist. :)


      Xaositect - Whitepages.com

        Which is why I'd probably defer adding the trailing comma until I knew I was actually going to add something else:

        $var .= join ', ', @stuff; $var .= ', ' . 'more stuff' if $moreStuffNeeded;

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.