in reply to Re^2: puts vs say
in thread puts vs say

I get it. I didn't say it does chomp, I said it should chomp.

-Paul

Replies are listed 'Best First'.
Re^4: puts vs say
by LanX (Saint) on Feb 28, 2009 at 13:10 UTC
    certainly other people would complain if say() chomps automatically!

    so what's wrong with defining your own puts() beside of say()

    DB<13> sub puts {my $x=pop; chomp($x); print @_,$x,"\n"} DB<14> puts 1,2,3,"a\n" 123a DB<15>
    Btw.
    • Does puts() take a list in ruby?
    • Are all elements chomped or just the last one?
    with your own solution you have full control about the behavior...

    Cheers Rolf

      For that matter, I could write my own output routines every time -- which I often do, and which usually corrects newline-ed-ness automagically. I just think the way say is defined presently is pretty pointless. Why even bother with it. I'd also like to point out that I'm not the OPer. This isn't my argument, I'm just agreeing with the OP.

      -Paul

        ... which usually corrects newline-ed-ness automagically.

        maybe I should make my my point clearer: IMHO DWIM-Magic has to be predictable and orthogonal.

        Chomping only the last parameter doesn't look orthogonal¹ to me. And I doubt that the group who doesn't want chomping is smaller than the other group. If I'm wrong this situation might only be solved by providing puts() additionally to say().

        I personally regularly redefine $\="\n" locally, to make print acting like say, so I think there is a wide need for say() ... but I never ever bothered about extra newlines.

        Perl isn't PHP or Cobol, you can't serve every tiny group ... they always have the possibility to use special modules for their needs.

        Cheers Rolf

        (¹) And I don't think we should make perl even more unorthogonal ...