in reply to Re: Value of a scalar specified by a second scalar
in thread Value of a scalar specified by a second scalar

Is there any reason or benefit to prefering
print $$want, $/;
over
print $$want, "\n";
I find myself tacking "\n" on the end of prints more often then I think I should.
Just wondering if there's a better way.

Replies are listed 'Best First'.
Re^3: Value of a scalar specified by a second scalar
by Zaxo (Archbishop) on May 18, 2006 at 04:08 UTC

    Only minor advantages. It's two fewer keystrokes and it makes output conform to the current input record seperator, which is sometimes good to ensure.

    Mainly, it's one of my coding habits. I formed it under the superstition that it's more platform neutral. That's not really true, but the minor advantages win for a habit I've already got.

    The truly handy way to stop fussing with newlines is to set local $\ = "\n"; and know that all distinct prints in that scope will get newlines appended.

    $ perl -e'local $\ = $/; print for qw/foo bar baz/' foo bar baz $

    After Compline,
    Zaxo