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.

In reply to Re^2: Labels, while loops and FastCGI by doink123
in thread Labels, while loops and FastCGI by doink123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.