in reply to println

a simple
sub println { local $\ = "\n"; print @_; }
would work too, with the added benefit of not actually being broken.

Replies are listed 'Best First'.
Re^2: println
by tadman (Prior) on Jun 07, 2002 at 20:11 UTC
    Getting feisty, aren't we?

    While I don't much see the use for an internal function named println, which reminds me of Pascal of all things, how about doing it correctly?
    sub println { print ((@_? join($/, @_) : $_), $/); }
    Not everyone uses UNIX, BeOS, or AmigaOS, so putting a literal "\n" in there is simply bad form.

    Update:
    As Dog and Pony points out, "\n" does represent a logical newline, as it is quietly and magically transformed into the appropriate value before being output. One could argue, though, that using $/ eliminates four shifted keystrokes.
      According to perlport, \n represents a logical newline, and thus (often) actually does the right thing across platforms.

      That said, nothing wrong with erring on the side of safety. :)


      You have moved into a dark place.
      It is pitch black. You are likely to be eaten by a grue.
A reply falls below the community's threshold of quality. You may see it by logging in.