Charles DeRykus writes:
> You could also simplify the closure  since @tasks is in the closure's
> lexical scope, eg,
> 
> my $report_static = sub {   print $tasks[$iter++]; ... };
> 
> foreach $task (@tasks) {
>       if (...)
>           $report_statics->();
>       else
>           $report_dynamic->();
>       ...
> }
> 
> But with everything in lexical scope, you could just  pass any needed
> arg's directly and
> eliminate the closure altogether.

        Many thanks. I actually did simply pass $task to each of
those subroutines then put
my $task = shift; inside the sub to copy the variable
and they now work like they should again or at least they began
to work after I installed the ; I forgot after the } on one of
the subs.

        The errors one gets when forgetting that semicolon are
almost as fun as the ones one gets when a { or } is missing or
there is an extra one from moving lines around. They tend to
point to everything but the real cause. The saving factor is
that they usually point to problems outside the scope of the
subroutine and flag code that was known to be good.  Move the
subroutine around and you poison everything after it

        I think the perl debugger is really clever in that it
usually guides you right to the problem and when it doesn't, one
can still get an idea roughly of what is wrong by the general
tone of the squawks.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to