in reply to Labels, while loops and FastCGI

Labels aren't package-specific; perl will go back up the calling stack until it finds an enclosing loop with the specified label.

So either you aren't in the middle of that while loop, or there's a bug in perl here.

Simple tests don't fail for me; can you come up with some code that shows the problem?

Replies are listed 'Best First'.
Re^2: Labels, while loops and FastCGI
by doink123 (Sexton) on Aug 01, 2004 at 20:34 UTC
    gaal, your solution is a very nice one and with some modifications will perfectly fit in my program. Thank you.

    ysth, I wrote a sample code to show how my program works and then I realized you were right - labels work fine if you call them from different packages. In my situation the program fails because I call end_request from $SIG{__DIE__}.
    This is the sample code:

    #!/usr/bin/perl package A; $SIG{__DIE__} = sub { end_request(@_); }; sub end_request { print @_; next LOOP; } print "start\n"; $x = 0; LOOP: while($x != 5) { $x++; #die "die\n" if $x == 3; end_request("die\n") if $x == 3; } print "end\n";


    If you use it like this it will work, but if you uncomment the #die "die\n" if $x == 3; line you will get a Label not found for "next LOOP" error. Using perl 5.8.4.