home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / perl / 7763 < prev    next >
Encoding:
Text File  |  1993-01-11  |  1.1 KB  |  50 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!data.nas.nasa.gov!ace.nas.nasa.gov!jns
  3. From: jns@ace.nas.nasa.gov (John N. Stewart)
  4. Subject: Re: bug with "last"
  5. References: <cameron-930111155241-1-06364@fuligin>
  6. Sender: news@nas.nasa.gov (News Administrator)
  7. Organization: NAS, NASA Ames Research Center, Moffett Field, California
  8. Date: Tue, 12 Jan 93 01:04:00 GMT
  9. Message-ID: <1993Jan12.010400.27973@nas.nasa.gov>
  10. Lines: 38
  11.  
  12. In article <cameron-930111155241-1-06364@fuligin> cameron@cs.unsw.oz.au writes:
  13. >This loop runs three times.
  14. >
  15. >    for (('a','b','c'))
  16. >        { print "\$_ is '$_'\n";
  17. >          { last; }
  18. >        }
  19.  
  20.  
  21. last terminates the block of code that it is in, which is limited by
  22. the {} around it. It never addresses the for loop. Running without
  23. those {} around the last gives the desired results.
  24.  
  25. % perl -version
  26. $RCSfile: perl.c,v $$Revision: 4.0.1.7 $$Date: 92/06/08 14:50:39 $
  27. Patch level: 34
  28.  
  29. % perl
  30.  
  31. for (('a','b','c'))
  32. { print "\$_ is '$_'\n";
  33.   { last; }
  34. }
  35. $_ is 'a'
  36. $_ is 'b'
  37. $_ is 'c'
  38.  
  39.  
  40.  
  41. % perl
  42.  
  43. for (('a','b','c'))
  44. { print "\$_ is '$_'\n";
  45. last;
  46. }
  47. $_ is 'a'
  48.  
  49.  
  50.