in reply to Re^3: list reversal closure
in thread list reversal closure

This actually makes the version without for more powerful!

Maybe, maybe not. Setting $, equal to $/ compromises your ability to use both for their designated purpose:

@array = map{ [ 'a'..'f' ] } 1 .. 6;; print @$_ for @array;; a b c d e f a b c d e f a b c d e f a b c d e f a b c d e f a b c d e f

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".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^5: list reversal closure
by ikegami (Patriarch) on Aug 21, 2006 at 16:18 UTC

    Apples and oranges. We were talking about print for reverse vs print reverse. for clearly compromises it:

    $, = ", "; $\ = "\n"; @array = map{ [ 'a'..'f' ] } 1 .. 6;; for (@array) { print for reverse @$_; } __END__ f e d c b a f e d c b a f e d c b a f e d c b a f e d c b a f e d c b a
    $, = ", "; $\ = "\n"; @array = map{ [ 'a'..'f' ] } 1 .. 6;; for (@array) { print reverse @$_; } __END__ f, e, d, c, b, a f, e, d, c, b, a f, e, d, c, b, a f, e, d, c, b, a f, e, d, c, b, a f, e, d, c, b, a

    Updated to use parent's @array.

      I don't get your latest point. What you've demonstrated is that if you want the array printed with just field separators, you do not use for, but if you want them printed one per line, you do use for.

      Your original point appeared to be saying that rather than use for to achieve the one per line output used in the OP, it would be better to set $, to a newline. I challenged that assumption, and you seem to have come back full circle.


      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".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Your original point appeared to be [...] it would be better to set $, to a newline.

        I don't know how you get "it would be better to set $, to a newline" from "It's more flexible." My point was the opposite, that you didn't have to set it to a newline.

        In the typical case ($, and $\ not used), eliminating the for eliminates a useless loop is eliminated.

        In the atypical case ($, and $\ used), eliminating the for allows the Field Seperator ($,) to be used as the field sperator. Before removing the for, the Line Seperator ($\) was used as both the Line Seperator and the Field Seperator.

        Update: Made the point even easier to read.