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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!gatech!concert!sas!mozart.unx.sas.com!kent
  3. From: kent@manzi.unx.sas.com (Paul Kent)
  4. Subject: or puzzlement
  5. Originator: kent@manzi.unx.sas.com
  6. Sender: news@unx.sas.com (Noter of Newsworthy Events)
  7. Message-ID: <BrtMFu.D0L@unx.sas.com>
  8. Date: Thu, 23 Jul 1992 02:47:54 GMT
  9. Nntp-Posting-Host: manzi.unx.sas.com
  10. Organization: SAS Institute Inc.
  11. Lines: 47
  12.  
  13.  
  14.  
  15. hi,
  16.  
  17. in some sub xx, i currently do the moral equivalent of:
  18.  
  19. sub xx
  20. {
  21.   opendir(D,$f) || warn "no dir $f" || return 1;
  22. }
  23.  
  24. which to my app is a non-fatal warning -- typically my outer loop
  25. will do 
  26.  
  27.   &sub() && next;
  28.  
  29.  
  30.  
  31.  
  32. is it guarenteed that warn <stuff> will evaluate
  33. to 0/false forcing the next thing in the or-sequence to be
  34. evaluated, or am i just getting "lucky" (warn in the camel
  35. book doesnt describe its result -- it may be grandfathered
  36. elsewhere....)
  37.  
  38.  
  39. i know i can do:
  40.  
  41. opendir(D,$f) || do
  42. { warn "no $f";
  43.   return 1;
  44. };
  45.  
  46.  
  47. but that seems ugly. is there a better idiom for things like
  48.  
  49.  dothis || warn_and_return
  50.  dothis || warn_and_next
  51.  
  52.  
  53.  
  54. thanks for any input on good perlstyle you might send...
  55. paul.
  56. -- 
  57.  
  58. Paul Kent (SQL r&d)                   " nothing ventured, nothing disclaimed "
  59. kent@unx.sas.com         SAS Institute Inc, SAS Campus Dr, Cary NC 27513-2414.
  60.