home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!portal!cup.portal.com!Eric-Amick
- From: Eric-Amick@cup.portal.com (Richard E Amick)
- Newsgroups: comp.lang.perl
- Subject: Re: How to output % symbol in perl
- Message-ID: <69857@cup.portal.com>
- Date: Thu, 19 Nov 92 16:48:20 PST
- Organization: The Portal System (TM)
- Distribution: usa
- References: <1992Nov19.004813.16052@leland.Stanford.EDU>
- Lines: 25
-
- >Suppose we run a file like the following:
- >
- >#! /usr/pubsw/bin/perl
- >printf STDOUT "\% A Latex Picture. \n";
- >
- >The output of the above file is:
- >A Latex Picture.
- >instead of the desired: % A Latex Picture.
- >
- >Any idea why the backslash does not protect the % symbol from
- >being interpreted ? And how may I output the % symbol with a perl script?
-
- printf uses the same format string conventions as the C library
- function; if you consult the man page, you'll see that you need:
-
- printf STDOUT "%% A Latex Picture. \n";
-
- While we're at it, this works just as well:
-
- print "% A Latex Picture. \n";
-
- Remember that STDOUT is the default filehandle for print, and you're not
- doing any formatting.
-
- Eric
-