$jmptaken would ALWAYS evaluate to the value it was set with, 1 and the loop never stops, 0 and it only runs once, no matter that the debug output always showed it being set in the corresponding subs correctly AND that the value was being passed to the loop conditional correctly.
Your code seems to be a confusion of the two approaches you mention. You say that $jmptaken is set 'in' a corresponding sub (approach 2) but from what I can see in your code it is being set by the return value of the sub, i.e. the return value from &LOOP or from &JMP (approach 1). No matter what you set it to 'in' the subs it will always take on the value returned from those subs.
Edit: If you do set $jmptaken in the subs LOOP and JMP, rather than use a global variable you could pass it as a reference to those subs:
if (uc($quickloop) eq 'LOOP') {
LOOP($quickloop, $quicklabel,\$isjmptaken);
}
...
sub LOOP {
my ($quickloop,$quicklabel,$isjmptaken_ref) = @_;
$$isjmptaken_ref = 1;
}
Note the use of $$ to dereference.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|