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

Somedays, I wish I could both ++ and -- a post. (Guess which one I ended up doing ...)

Yes, use the strictures. But, don't use the commandline flags in a production script! Good Gods, man, are you trying to get the OP to write obfuscated code?!? Who looks at the shebang line? If I were to read that code, I would be going bonkers trying to figure out how the newline was getting in there, and I golf with -l on a regular basis. (He shoots a 14 handicap, in case you're wondering.)

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^4: printing a scalar as an array
by blazar (Canon) on Feb 24, 2005 at 09:40 UTC
    But, don't use the commandline flags in a production script! Good Gods, man, are you trying to get the OP to write obfuscated code?!? Who looks at the shebang line?
    Well, I think that -l is safe enough in short enough scripts. So it all depends on how short the production script will be, and of course a "production script", whatever it could be, tends to give the idea of being a rather longish thing, or if it is not, it's still likely to grow into one, so I think that you're right in the vast majority of cases.

    I think I have a tendency to overuse -l myself, because I like not to have to include literal newlines. But then when I want both this and to be safe I do

    { local $\="\n"; # or $/, if it's not been changed... print whatever; print something_else; # ... }

    Of course if we had Perl6's say() we wouldn't be bothered, but then someone will certainly point out that we already have a module for that. OTOH, IMHO it could easily leak into the core in some next major perl5 release, couldn't it?