Newsgroups: comp.lang.perl
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!convex!usenet
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: Stupid perl question
Message-ID: <1991Jun30.200909.16230@convex.com>
Sender: usenet@convex.com (news access account)
Nntp-Posting-Host: pixel.convex.com
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: CONVEX Software Development, Richardson, TX
References: <1991Jun30.180310.22394@decuac.dec.com>
Distribution: usa
Date: Sun, 30 Jun 1991 20:09:09 GMT
Lines: 30

From the keyboard of klr@decuac.dec.com (Kurt Reisler -- UNISIG Chairman):
:I am sure this has been asked before (therefore, it is a stupid
:question", but if I want to print out a percentage mark in a printf
:statement (as in printf "% changed"), what is the best (note, no
:reference to "proper", because I know better) to do it?  Oh yes, I am
:still using version 3.0 PL44 (I think).

First, don't call printf if you don't need to.  

    print "% changed";

works just fine.  

Also, be very wary of the common error of:

    $foo = <STDIN>;
    printf "you said $foo";  

because what if they had a % in their string?  Try !?%silly
in the csh for a good time (but not from your login shell. :-).

Finally, if you really want to use a literal %, it's as in C,
you double it:

    printf "%% has changed %5d times", $count;

--tom
--
Tom Christiansen		tchrist@convex.com	convex!tchrist
		"So much mail, so little time."  
