home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / perl / 4914 < prev    next >
Encoding:
Text File  |  1992-07-23  |  1.8 KB  |  61 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!hermes.chpc.utexas.edu!news.utdallas.edu!convex!tchrist
  3. From: Tom Christiansen <tchrist@convex.COM>
  4. Subject: Re: or puzzlement
  5. Message-ID: <1992Jul23.194053.28653@news.eng.convex.com>
  6. Originator: tchrist@pixel.convex.com
  7. Sender: usenet@news.eng.convex.com (news access account)
  8. Nntp-Posting-Host: pixel.convex.com
  9. Reply-To: tchrist@convex.COM (Tom Christiansen)
  10. Organization: CONVEX Realtime Development, Colorado Springs, CO
  11. References: <BrtMFu.D0L@unx.sas.com> <MERLYN.92Jul23070028@romulus.reed.edu> <Brut2B.80J@unx.sas.com>
  12. Date: Thu, 23 Jul 1992 19:40:53 GMT
  13. X-Disclaimer: This message was written by a user at CONVEX Computer
  14.               Corp. The opinions expressed are those of the user and
  15.               not necessarily those of CONVEX.
  16. Lines: 43
  17.  
  18. From the keyboard of kent@manzi.unx.sas.com (Paul Kent):
  19. :# how to generalize that comma trick to "next" ...
  20.  
  21. Hey guys, there's nothing wrong with a few braces, or parens.
  22.  
  23. :for $d ($d1,$d2)
  24. :{
  25. :    opendir(D, $d) || warn "loop_comma: no $d", next;
  26. :    print STDERR "loop_comma: $d must exist cuz we got this far\n"; 
  27. :}
  28.  
  29. You want:
  30.  
  31.     for $d ($d1,$d2) {
  32.     opendir(D, $d) || warn("loop_comma: no $d"), next;
  33.     print STDERR "loop_comma: $d must exist cuz we got this far\n"; 
  34.     }
  35.  
  36. or
  37.  
  38.     for $d ($d1,$d2) {
  39.     opendir(D, $d) || do { warn "loop_comma: no $d"; next; }
  40.     print STDERR "loop_comma: $d must exist cuz we got this far\n"; 
  41.     }
  42.  
  43.  
  44. or
  45.  
  46.     for $d ($d1,$d2) {
  47.     unless (opendir(D, $d)) {
  48.         warn "loop_comma: no $d"; 
  49.         next;
  50.     }
  51.     print STDERR "loop_comma: $d must exist cuz we got this far\n"; 
  52.     }
  53.  
  54.  
  55. --tom
  56. -- 
  57.     Tom Christiansen      tchrist@convex.com      convex!tchrist
  58.  
  59.     #else /* !STDSTDIO */     /* The big, slow, and stupid way */
  60.         --Larry Wall in str.c from the perl source code
  61.