Re: An issue of Scope that I do not understand

2015-02-28 Thread Martin G. McCormick
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_dynami

Re: An issue of Scope that I do not understand

2015-02-28 Thread Charles DeRykus
> ... > > I'm not sure why you don't just pass $task as an argument to the > report_xxx subs...? > > A closure (perldoc -q closure) would be the long way around unless > I've missed something: > > my $task; > my $iter; > my $report_static = sub { my $ref = shift; >

Re: An issue of Scope that I do not understand

2015-02-28 Thread Shlomi Fish
Hi Martin, thanks for your kind words. On Sat, 28 Feb 2015 09:01:26 -0600 "Martin G. McCormick" wrote: > Shlomi Fish writes: > http://perl-begin.org/tutorials/bad-elements/#declaring_all_vars_at_top > > > > (Note: perl-begin.org is a domain I originated and maintain). > > Shlomi Fish, Uri and

Re: An issue of Scope that I do not understand

2015-02-28 Thread Martin G. McCormick
Shlomi Fish writes: http://perl-begin.org/tutorials/bad-elements/#declaring_all_vars_at_top > > (Note: perl-begin.org is a domain I originated and maintain). Shlomi Fish, Uri and Brock, I certainly wish I had known about a resource like this earlier in my relatively short perl career.

Re: An issue of Scope that I do not understand

2015-02-28 Thread Shlomi Fish
Hi Martin, here are some comments on your code in addition to what Uri said. On Fri, 27 Feb 2015 22:24:52 -0600 "Martin G. McCormick" wrote: > Brock Wilcox writes: > > I'm afraid a bit more context is needed to identify the problem. Could you > > post your entire bit of code into a gist or past

Re: An issue of Scope that I do not understand

2015-02-27 Thread Charles DeRykus
On Fri, Feb 27, 2015 at 8:24 PM, Martin G. McCormick wrote: > Brock Wilcox writes: >> I'm afraid a bit more context is needed to identify the problem. Could you >> post your entire bit of code into a gist or pastebin or something for us >> to >> see? > > I'll do better than that. This is a

Re: An issue of Scope that I do not understand

2015-02-27 Thread Uri Guttman
On 02/27/2015 11:24 PM, Martin G. McCormick wrote: Brock Wilcox writes: I'm afraid a bit more context is needed to identify the problem. Could you post your entire bit of code into a gist or pastebin or something for us to see? I'll do better than that. This is a script which is strippe

Re: An issue of Scope that I do not understand

2015-02-27 Thread Martin G. McCormick
Brock Wilcox writes: > I'm afraid a bit more context is needed to identify the problem. Could you > post your entire bit of code into a gist or pastebin or something for us > to > see? I'll do better than that. This is a script which is stripped of everything but the problem code. It is 2

Re: An issue of Scope that I do not understand

2015-02-27 Thread Brock Wilcox
I'm afraid a bit more context is needed to identify the problem. Could you post your entire bit of code into a gist or pastebin or something for us to see? On Feb 27, 2015 9:52 PM, "Martin G. McCormick" < mar...@server1.shellworld.net> wrote: > I put together an anonymous subroutine which

An issue of Scope that I do not understand

2015-02-27 Thread Martin G. McCormick
I put together an anonymous subroutine which partly works. There is an array called @tasks which is defined as a local variable in the main routine and when I call the anonymous subroutine, one can still read all the elements in @tasks. There is also a single scaler called $task, a