home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / perl / 5869 < prev    next >
Encoding:
Internet Message Format  |  1992-09-11  |  1.3 KB

  1. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!spool.mu.edu!olivea!tymix!cirrus!lando
  2. From: lando@cirrus.com (Dave Landis)
  3. Newsgroups: comp.lang.perl
  4. Subject: MS-DOS version of Perl
  5. Message-ID: <1992Sep11.163320.1837@cirrus.com>
  6. Date: 11 Sep 92 16:33:20 GMT
  7. Sender: news@cirrus.com
  8. Organization: Cirrus Logic Inc.  Fremont, California
  9. Lines: 33
  10. Originator: lando@tango
  11.  
  12.  
  13. Using the subroutine y_or_n from page 53 in the Camel Book,
  14. I wrote the following on my Sparc2 workstation.
  15. -----------------------------------
  16. #! /cirrus/bin/perl
  17. #
  18.  
  19. if( &y_or_n ("the answer is yes [y|n]:  ")) {
  20.    printf("The answer was yes!\n");
  21. }
  22.  
  23. if(! &y_or_n ("the answer is no [y|n]:  ")) {
  24.    printf("The answer was no!\n");
  25. }
  26.  
  27. sub y_or_n {
  28.     local($prompt) = @_;
  29.     printf STDOUT $prompt;
  30.     local($answer) = scalar(<STDIN>);
  31.     $answer =~ /^y/i;
  32. }
  33.  
  34. #
  35. # yesOrno
  36. #
  37. -----------------------------------
  38. This routine works just fine on my Sparc2.  However, I downloaded to my
  39. PC and my PC version of Perl did not like the useage of scalar.  Are there
  40. any other users that have encountered a similar problem?
  41. -- 
  42. "He is the best friend of American liberty who is most sincere and active
  43.  in promoting pure and undefiled religion." John Witherspoon, signer of the
  44.  Declaration of Independence.
  45.