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

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.

Replies are listed 'Best First'.
Re^8: list reversal closure
by BrowserUk (Patriarch) on Aug 21, 2006 at 17:26 UTC
    I don't know how you get "it would be better to set $, to a newline" from "It's more flexible."

    Your original post, quoted here for continuity of context,

    Nit: print for reverse @list; is equivalent to print reverse @list; when $, and $\ are equal (as they are by default).

    Made no mention of flexibility.

    You nit picked the OP's code implying that his use of for was redundant if $, and $\ were the same. I pointed out that this was not the case with the OP's code.

    I drew the inference from that post and your next that you think that setting $, to "\n" was better than his use of a for loop. I drew this inference because without that, your original post made no sense.

    Unless you take the step of setting $. = "\n",

    print reverse @list;

    produces entirely different results from

    print for reverse @list:

    If you were not so implying, I wonder why you bothered to throw this piece of--correct, but disconnected--information into the thread in the first place?


    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.
      I pointed out that this was not the case with the OP's code.

      Actually, you pointed out that this was not the case with -l. There was no mention of the OP using -l, and I hadn't noticed 'til now. That changes everything.

        Actually, he said "Notice the -l on his shebang line," in his first response to you. You probably just overlooked the use of the word "his" in that.

        You did bring up an interesting point, perhaps accidentally, though: Should my program linebreak between list elements, or after the list output?

        print substr("Just another Perl hacker", 0, -2);
        - apotheon
        CopyWrite Chad Perrin