Labels are very useful for breaking out of nested loops:
LOOP1: while (condition1) {
LOOP2 while (condition2) {
last LOOP1 if (fatal error);
}
}
On 29 Jun 2001 16:17:54 +0200, Aaron Craig wrote:
> ALL_CAPS:
> is a label that sets off a block of code. A more obvious use for it would
> be to emulate the switch structure in C++:
> SWITCH:
> {
> if($var == 1)
> {
> do something
> last SWITCH; # skip the rest of this block
> }
> if($var == 2)
> {
> do something else
> last SWITCH; # skip the rest of this block
> }
> do some default thing
> }
>
> basically, a string followed by a colon is a point in the code that you can
> tell the program to go to using keywords like next, last, etc.
>
> somewhere in your script, there must be a reference to ALL_SESSIONS and
> ALL_STUDIES -- hopefully not using the dreaded goto! :)
> At 09:10 29.06.2001 -0500, Humberto Varela wrote:
> >sorry to ask such a simple question, but i can't find reference to this
> >syntax in a couple of my Perl reference books (i think it's time i bought
> >the Camel book)
> >
> >----------
> >
> >
> >ALL_SESSIONS: foreach $session_dir (@ARGV) {
> > @studies = `ls -1 "$session_dir" `;
> > @session_path = split /\//, $session_dir ;
> > $session = $session_path[$#session_path] ;
> > print "\n Checking $session:" ;
> >
> > ALL_STUDIES: foreach $study (@studies) {
> > chomp $study;
> > $numfound = 0;
> > @hits = (); # new list
> >
> >----------
> >
> >the items in CAPS: are some kind of structure, right?
> >
> >i just haven't seen the CAPS: notation yet.
> >
> >thanks.
>
> Aaron Craig
> Programming
> iSoftitler.com
>
>
--
Today is Setting Orange, the 34th day of Confusion in the YOLD 3167
Fnord.