Path: utzoo!mnetor!tmsoft!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!cs.utexas.edu!convex!tchrist From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: Newlines in prints Message-ID: <1991Feb20.172023.13416@convex.com> Date: 20 Feb 91 17:20:23 GMT References: <1991Feb20.155958.8027@uvaarpa.Virginia.EDU> Sender: tchrist@convex.com (Tom Christiansen) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 36 From the keyboard of worley@compass.com: : From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) : : Well, you can save two characters by defining $n = "\n", but it sounds : more like you want to set $\ to "\n" and then have a subroutine for : printing without the newline: : :This leaves various problems, mostly that setting $\ makes adding the :newlines mandatory. Also, a subroutine for printing won't have the :same syntax as "print". What I want is a quick-n-easy punctuation :mark that can be inserted at the end (and preferably anywhere) I don't see what a special token, like NL (or your own $N), would gain you over "\n". It doesn't seem worth it. Modulo file-handles not getting commas, &print and &println functions would look just like print's but with parens, wouldn't they? sub print { print @_; } sub println { print @_, "\n"; } Tacking on a newline doesn't seem to my mind enough hassle to justify further obfuscating the language with another print function or a magic token or variable. print "this is a foo: ", $foo; print "this is a newline foo", $foo, ; # <- trailing comma trigger NL This sounds too much like BASIC, which perl really isn't. That comma is hard to see, and anything bigger undoes any convenience. Now, swrite may be a whole nother matter. --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "All things are possible, but not all expedient." (in life, UNIX, and perl)