home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / perl / 7064 < prev    next >
Encoding:
Internet Message Format  |  1992-11-19  |  1.0 KB

  1. Path: sparky!uunet!portal!cup.portal.com!Eric-Amick
  2. From: Eric-Amick@cup.portal.com (Richard E Amick)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: How to output % symbol in perl
  5. Message-ID: <69857@cup.portal.com>
  6. Date: Thu, 19 Nov 92 16:48:20 PST
  7. Organization: The Portal System (TM)
  8. Distribution: usa
  9. References:  <1992Nov19.004813.16052@leland.Stanford.EDU>
  10. Lines: 25
  11.  
  12. >Suppose we run a file like the following:
  13. >
  14. >#! /usr/pubsw/bin/perl
  15. >printf STDOUT "\% A Latex Picture. \n";
  16. >
  17. >The output of the above file is:
  18. >A Latex Picture. 
  19. >instead of the desired: % A Latex Picture.
  20. >
  21. >Any idea why the backslash does not protect the % symbol from 
  22. >being interpreted ? And how may I output the % symbol with a perl script?
  23.  
  24. printf uses the same format string conventions as the C library
  25. function; if you consult the man page, you'll see that you need:
  26.  
  27. printf STDOUT "%% A Latex Picture. \n";
  28.  
  29. While we're at it, this works just as well:
  30.  
  31. print "% A Latex Picture. \n";
  32.  
  33. Remember that STDOUT is the default filehandle for print, and you're not
  34. doing any formatting.
  35.  
  36. Eric
  37.