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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!howland.reston.ans.net!usc!news.service.uci.edu!ucivax!ucla-cs!ucla-ma!julia!jbence
  3. From: jbence@julia.math.ucla.edu (James K. Bence)
  4. Subject: Re: bug with "last"
  5. Message-ID: <1993Jan11.161034.9577@math.ucla.edu>
  6. Summary: I don't think so
  7. Sender: news@math.ucla.edu
  8. Organization: UCLA Mathematics Department
  9. References: <cameron-930111155241-1-06364@fuligin>
  10. Date: Mon, 11 Jan 93 16:10:34 GMT
  11. Lines: 25
  12.  
  13. In article <cameron-930111155241-1-06364@fuligin> cameron@cs.unsw.oz.au writes:
  14. >This loop runs three times.
  15. >
  16. >    for (('a','b','c'))
  17. >        { print "\$_ is '$_'\n";
  18. >          { last; }
  19. >        }
  20. >
  21. >Surely it shouldn't? This is perl 4.035.
  22. >    - Cameron Simpson
  23. >      cameron@cse.unsw.edu.au, DoD 0743
  24. >--
  25.  
  26. I think it should.  The 'last' terminates the block within which it is 
  27. enclosed, which happens to be very short.  I point to the Camel, pg. 97:
  28.  
  29. "A BLOCK by itself (labeled or not) is equivalent to a loop that executes
  30. once.  Thus you can use 'last' to leave the block or redo to restart
  31. the block."       (An example follows in the text)
  32.  
  33. James Bence
  34. Programmer/Analyst/Grad Student
  35. Univ. of Calif, Los Angeles
  36. Dept. of Mathematics
  37. jbence@math.ucla.edu
  38.