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

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. with your own solution you have full control about the behavior...

Cheers Rolf

Replies are listed 'Best First'.
Re^5: puts vs say
by jettero (Monsignor) on Feb 28, 2009 at 13:13 UTC
    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 ...
        What I'm saying is: why bother with say at all. Why not write your own say that does what you want? If say is meant to be a convenience function, then it should actually *be convenient*.

        -Paul