Philip Potter <philip.g.pot...@gmail.com> writes:

> On 5 May 2010 17:29, Harry Putnam <rea...@newsguy.com> wrote:
>> Anyway, I understood he was saying NOT global.
>>
>> What I asked is why that would matter.  That is, the values or
>> elements in @_ arrive inside the `sub dispt {...}', so should be
>> available to anything inside `sub dispt {...}'  right?
>>
>> And `%hash = (...)' is inside `sub dispt {. %hash = (...)..}'
>>
>> I do get confused often about how scope works.
>
> Did you read the second part of my message where I addressed this very
> issue? You haven't quoted it or answered it so I have nothing to say
> other than to ask you to read it again and tell me what you still find
> confusing.

I'm sorry, I skipped right over it somehow. It appeared you only
commented on what Uri had to say.  I didn't scroll far enough, so it
appeared it was just the quoted code below you comments about `FF'.

That explains whats happening better.  And I see now... I'm going
about this all wrong. Nesting isn't really what I'm after.

Looks like it would be better to just rely on global variables to
supply needed information inside whatever subroutines are called in
the dispatch table.  In fact someone suggested just that
earlier... and I didn't follow what they were talking about.

But after finally reading your comments.. I'm thinking to stick with
something more like this pattern.

,----
|  @ar ## already with data inside (global)
| 
| sub dispatch {
|       %hash  = (
|                 N => \&N,   
|                 N => \&O,   
|                 N => \&P,   
|                  [...]
|            );
|   while {
|    [...]
|   }
| }
| sub N { do something with (global) @ar}
| 
|  [...] more subs
`----



-- 
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