I like -l but wish that there was a way to selectively counter-act it, as I occasionally (but not often) want to print a newline-less line. How do you handle these situations?
Localize $\.
$\ = "\n"; # as perl -l
print "before";
{
local $\;
print "continued";
}
print "after";
print "heh!";
which prints
before
continuedafter
heh!
In fact, you can set $\ to anything, and with
local, it's safe — or at least, as safe as using $\.
IMO, every module that uses print in a hidden fashion, should use
local $\;
and not rely on $\ being empty at the time its functions are called.
Note that printf ignores the settings of $\.