home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5575 < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.2 KB  |  38 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!usc!sol.ctr.columbia.edu!eff!ckd
  3. From: ckd@eff.org (Christopher Davis)
  4. Subject: Re: help with if ( ! $a =~ /##/ ) PLEASE!!!
  5. In-Reply-To: ericw@bach.amd.com's message of 27 Aug 92 20:02:55 GMT
  6. Message-ID: <CKD.92Aug27231701@loiosh.eff.org>
  7. Sender: usenet@eff.org (NNTP News Poster)
  8. Nntp-Posting-Host: loiosh.eff.org
  9. Organization: Electronic Frontier Foundation Tech Central
  10. References: <ericw.714945775@bach>
  11. Distribution: usa
  12. Date: Fri, 28 Aug 1992 03:17:03 GMT
  13. Lines: 23
  14.  
  15. Eric> == Eric Wedaa <ericw@bach.amd.com> 
  16.  
  17.  Eric> I am having a h!@# of a time getting this code fragment to 
  18.  Eric> work:
  19.  
  20.  Eric> if ( ! $a =~ /#/ ){
  21.  Eric>     some_random_bit_of_perl;
  22.  Eric> }
  23.  
  24.  Eric> It never does anything!  What I want it to do is if $a does not 
  25.  Eric> have "#" in it, then it should do "some_random_bit_of_perl;"
  26.  
  27. Why not do this instead:
  28.  
  29. if ($a !~ /#/) {
  30.         some_random_bit_of_perl;
  31. }
  32.  
  33. This is (IMHO) cleaner than a test-and-negate.
  34. --
  35. Christopher Davis * ckd@eff.org * System Administrator, EFF * +1 617 864 0665
  36.             ``Ed Gruberman, you fail to grasp Ti Kwan Leep.
  37.             Approach me that you might see.'' -- The Master
  38.