in reply to Re^4: printing a scalar as an array
in thread printing a scalar as an array

Update: As for the 'perl -l' - I would lean away from that, but I have no real reasons I could back up. Why not just ($\="\n") ?

For the same reason that you shouldn't say something like:

*CORE::log = sub { # Your logging code here }
in some module buried three layers deep in your application infrastructure, just so you can write
do_some_operation( @args ) or log( "some_operation() failed with @args!" );

Can you see the problem? What about if I wanted to add some mathematical functionality to this application that required the use of logarithms and the log() builtin function?

The point is that you never want to violate the "Principle of Least Surprise". There are many, many community expectations in terms of how code will behave. One is that print() does not append a newline. If it suddenly starts doing so, I know I'd get very confused and spend a lot of time trying to figure out why. Modifying $\ or adding -l to the commandline is a very quiet way of making a very large global change that will confuse people who try and read your code, especially after you no longer work there.

Remember - your code belongs to your employer and you have a responsability to make sure that maintenance of said code is as cost-efficient as possible.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^6: printing a scalar as an array
by RazorbladeBidet (Friar) on Feb 23, 2005 at 14:23 UTC
    Duly noted.

    How about then:
    local $\="\n";


    I understand what you are saying about the PoLS, however. I do not intend to go changing to use that, just seeing how that applies to your point above.
    --------------
    It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs