home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- 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
- From: jns@ace.nas.nasa.gov (John N. Stewart)
- Subject: Re: bug with "last"
- References: <cameron-930111155241-1-06364@fuligin>
- Sender: news@nas.nasa.gov (News Administrator)
- Organization: NAS, NASA Ames Research Center, Moffett Field, California
- Date: Tue, 12 Jan 93 01:04:00 GMT
- Message-ID: <1993Jan12.010400.27973@nas.nasa.gov>
- Lines: 38
-
- In article <cameron-930111155241-1-06364@fuligin> cameron@cs.unsw.oz.au writes:
- >This loop runs three times.
- >
- > for (('a','b','c'))
- > { print "\$_ is '$_'\n";
- > { last; }
- > }
-
-
- last terminates the block of code that it is in, which is limited by
- the {} around it. It never addresses the for loop. Running without
- those {} around the last gives the desired results.
-
- % perl -version
- $RCSfile: perl.c,v $$Revision: 4.0.1.7 $$Date: 92/06/08 14:50:39 $
- Patch level: 34
-
- % perl
-
- for (('a','b','c'))
- { print "\$_ is '$_'\n";
- { last; }
- }
- $_ is 'a'
- $_ is 'b'
- $_ is 'c'
-
-
-
- % perl
-
- for (('a','b','c'))
- { print "\$_ is '$_'\n";
- last;
- }
- $_ is 'a'
-
-
-