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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!news.Brown.EDU!noc.near.net!meiko.com!mike
  3. From: mike@meiko.com (Mike Stok)
  4. Subject: Re: Empty IF-TRUE-EXPR in ?:
  5. Message-ID: <1992Jul22.105757.5332@meiko.com>
  6. Sender: news@meiko.com
  7. Organization: Meiko Scientific Corp.
  8. References: <BRENDAN.92Jul21221748@eff.org>
  9. Distribution: usa
  10. Date: Wed, 22 Jul 1992 10:57:57 GMT
  11. Lines: 31
  12.  
  13. In article <BRENDAN.92Jul21221748@eff.org> brendan@eff.org writes:
  14. >
  15. >I was thinking, it'd be nice to be able to have
  16. >
  17. >    $foo ? $foo : 4;
  18. >
  19. >be also available as
  20. >
  21. >    $foo ? : 4;
  22. >
  23. >to avoid re-parsing the second case of $foo.  (Where $foo could be any
  24. >arbitrarily large expression.)
  25.  
  26. won't something like $bar = $foo || 4; do the trick?
  27.  
  28. try ('' and 0 both evaluate to false):
  29.  
  30. foreach $foo ('', ' ', 0, 99, 'gibberish')
  31. {
  32.   $bar = $foo || 4;
  33.   print "foo = <$foo>, bar = <$bar>\n";
  34. }
  35.  
  36.  
  37. Mike
  38.  
  39. --
  40. The "usual disclaimers" apply.    | ... many were weak and confused, succumbing
  41. Mike Stok                         | to drink or drugs whenever possible ...
  42. mike@meiko.com                    |
  43. Meiko tel: (617) 890 7676         |                          Hunter S. Thompson
  44.