Shlomi Fish writes:
> Hi Harry,
>
> thanks for replying inline (bottom posting).
>
> On Thursday 06 May 2010 16:19:32 Harry Putnam wrote:
>> Shlomi Fish writes:
>>
>>
>> [...]
>>
>> > sub dispatch
>> > {
>> >
>> >my ($method, @rest_of_args) = @_;
>>
>> Not sure what $method is supposed
Hi Harry,
thanks for replying inline (bottom posting).
On Thursday 06 May 2010 16:19:32 Harry Putnam wrote:
> Shlomi Fish writes:
>
>
> [...]
>
> > sub dispatch
> > {
> >
> > my ($method, @rest_of_args) = @_;
>
> Not sure what $method is supposed to be doing.
>
Sorry, I'm usually used
Shlomi Fish writes:
[...]
> sub dispatch
> {
> my ($method, @rest_of_args) = @_;
Not sure what $method is supposed to be doing.
> my %dispatch =
> (
> 'N' => sub { return N_func(@rest_of_args); },
> 'L' => sub { return L_func(@rest_of_args); },
>
Harry Putnam writes:
Egad... I'm messing up what I want to say way too much.
There is an unfortunate type in there...
> But after finally reading your comments.. I'm thinking to stick with
> something more like this pattern.
>
> ,
> | @ar ## already with data inside (global)
> |
> | sub
Akhthar Parvez K writes:
> Why are you calling the subroutine N? Have you already defined a
> subroutine with the name N in your program?
Yes, it was already defined... and I see now how I was nesting a
second call in there... not really what was needed or intended.
thanks.
--
To unsubscri
Thomas Bätzler writes:
>> sub func { %h = ( N => sub { print N(@_) . "\n"; } ); }
>
> If you call the sub like this, it'll create the hash %h containing the
> key "N" associated with a code reference to an anonymous
> subroutine. When that subroutine is called it will pass its _current_
> argumen
On Thursday 06 May 2010 13:24:10 Harry Putnam wrote:
> Philip Potter writes:
> > On 5 May 2010 17:29, Harry Putnam 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
Harry Putnam writes:
> . . . . ... I'm still not seeing why the
> values in @_ are not available at the call to N() inside like this:
> (incomplete code)
Disregard above.
Sorry about the line noise... I missed the main part of
Phillips' explanation
--
To unsubscribe, e-mail: beginners
Philip Potter writes:
> On 5 May 2010 17:29, Harry Putnam 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 {
On Wednesday 05 May 2010, Harry Putnam wrote:
> But even though I can work with that... I'm still not seeing why the
> values in @_ are not available at the call to N() inside like this:
> (incomplete code)
>
> func($val1,$val2);
>
> sub func { %h = ( N => sub { print N(@_#HERE) . "\n"; } ); }
Harry Putnam asked:
> But even though I can work with that... I'm still not seeing why the
> values in @_ are not available at the call to N() inside like this:
> (incomplete code)
>
> func($val1,$val2);
>
> sub func { %h = ( N => sub { print N(@_) . "\n"; } ); }
If you call the sub like this,
"Uri Guttman" writes:
>> "HP" == Harry Putnam writes:
>
> HP> A third sub function is called in the dispatch table ( N(@_); ) but
> HP> the variables don't survive to be use there.
>
> there are no variables to survive in a sub, just passed arguments in @_
>
> HP> The output from the s
On 5 May 2010 17:29, Harry Putnam 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 =
Thomas Bätzler writes:
> Harry Putnam asked:
> [...]
>> which is also inside sub dispt {the sub function}. Where does global
>> come in?
>
> Hint: $code->(@_);
Yes, I knew it could be done there... but what to do then when more
function calls are added.
Are you thinking something like:
i
Philip Potter writes:
> On 5 May 2010 14:36, Harry Putnam wrote:
>> "Uri Guttman" writes:
>>
>>> HP> The output from the script below:
>>> HP> Shows 6 elements arrive in dispt($g, @ar) as @_. But when sub N(@_)
>>> HP> is called, no variables arrive there. @_ is empty. When it seems like
On 5 May 2010 15:26, Thomas Bätzler wrote:
> Harry Putnam asked:
> [...]
>> which is also inside sub dispt {the sub function}. Where does global
>> come in?
>
> Hint: $code->(@_);
Or indeed &$code; if you want to be cryptic :)
Phil
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For
On 5 May 2010 14:36, Harry Putnam wrote:
> "Uri Guttman" writes:
>
>> HP> The output from the script below:
>> HP> Shows 6 elements arrive in dispt($g, @ar) as @_. But when sub N(@_)
>> HP> is called, no variables arrive there. @_ is empty. When it seems like
>> HP> 5 elements should hav
Harry Putnam asked:
[...]
> which is also inside sub dispt {the sub function}. Where does global
> come in?
Hint: $code->(@_);
HTH,
Thomas
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
"Uri Guttman" writes:
> HP> The output from the script below:
> HP> Shows 6 elements arrive in dispt($g, @ar) as @_. But when sub N(@_)
> HP> is called, no variables arrive there. @_ is empty. When it seems like
> HP> 5 elements should have arrived there
>
> well, it helps if you actuall
> "HP" == Harry Putnam writes:
HP> A third sub function is called in the dispatch table ( N(@_); ) but
HP> the variables don't survive to be use there.
there are no variables to survive in a sub, just passed arguments in @_
HP> The output from the script below:
HP> Shows 6 elements
A mock up of dispatch table.
No dispatching done here... only a test of passing values.
What am running into here? one sub function called
(dispt('hello',@ar); )
containing a dispatch table.
A third sub function is called in the dispatch table ( N(@_); ) but
the variables don't survive to be use
Steve Bertrand writes:
> First note that this will run forever :)
Yup... for a second there I thought I'd inadvertently pressed `y' at
the linux prompt...
> Also, there's no proper conditional logic involved here, the dispatch
> table subs are just calling back to other subs from within the di
On 2010.04.28 22:04, Harry Putnam wrote:
> Your reference to `call back' is probably just the ticket... but I
> will show actual code that tries to do what I need, and maybe you can
> show how a `call back would work.
This is pretty simple and has no inherent complexity whatsoever, but
hopefully
Steve Bertrand writes:
First off let me thank you for the time and effort involved in replying.
> On 2010.04.26 15:24, Harry Putnam wrote:
>
>> I want to try to describe briefly what problem I'm having.
>> But not show any working code.
>
> That's ok, but it isn't clear to me that you have reall
On 2010.04.26 15:24, Harry Putnam wrote:
> I hope some of you will go along with this approach.
>
> I want to try to describe briefly what problem I'm having.
> But not show any working code.
>
> I've made so much of a mess trying a lot of different things I'd like
> to have some idea that at lea
On 2010.04.26 15:24, Harry Putnam wrote:
> I hope some of you will go along with this approach.
>
> I want to try to describe briefly what problem I'm having.
> But not show any working code.
>
> I've made so much of a mess trying a lot of different things I'd like
> to have some idea that at lea
On 2010.04.26 15:24, Harry Putnam wrote:
> I want to try to describe briefly what problem I'm having.
> But not show any working code.
That's ok, but it isn't clear to me that you have really described a
problem that you are stuck on.
> I guess where I get stuck is how to make a dispatch table w
I hope some of you will go along with this approach.
I want to try to describe briefly what problem I'm having.
But not show any working code.
I've made so much of a mess trying a lot of different things I'd like
to have some idea that at least theoretically I'm on the right track
(or wrong track
Shawn H Corey writes:
> Harry Putnam wrote:
>> Harry Putnam writes:
>>
>>> However, using your suggestion:
>>> > $code->($var1, $var2);
>>
>> Something I forgot to ask about that.
>>
>> What if more than 1 of referenced sub routines needed vars passed in
>> but the needed vars were not the sam
Ireneusz Pluta writes:
> Harry Putnam wrote:
>> I don't see the expected result when I press `y'.
> you never print it
errr... yup, (corrective action taken).
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.
Harry Putnam wrote:
I don't see the expected result when I press `y'.
you never print it
(The code is at the end)
It seems to do nothing.
...
non working code:
#!/usr/local/bin/perl
use strict;
use warnings;
my $var1 = 'whoopdee';
my $var2 = 'do';
my %dispatch = (
y => \&yy,
On Sat, 24 Apr 2010 10:06:37 -0500, Harry Putnam wrote:
> Harry Putnam writes:
>
>
>> However, using your suggestion:
>> > $code->($var1, $var2);
>
> Something I forgot to ask about that.
>
> What if more than 1 of referenced sub routines needed vars passed in but
> the needed vars were not
Harry Putnam wrote:
Harry Putnam writes:
However, using your suggestion:
> $code->($var1, $var2);
Something I forgot to ask about that.
What if more than 1 of referenced sub routines needed vars passed in
but the needed vars were not the same?
I'm guessing that using $code->() is not suc
Harry Putnam writes:
>
> However, using your suggestion:
> > $code->($var1, $var2);
Something I forgot to ask about that.
What if more than 1 of referenced sub routines needed vars passed in
but the needed vars were not the same?
I'm guessing that using $code->() is not such a good idea. Wh
Harry Putnam wrote:
Ireneusz Pluta writes:
Harry Putnam wrote:
#!/usr/local/bin/perl
use strict;
use warnings;
my $var1 = 'whoopdee';
my $var2 = 'do';
my %dispatch = (
y => \&yy($var1,$var2),
this, actually, is not a code reference but a return value reference
of the &yy($var1,
Ireneusz Pluta writes:
> Harry Putnam wrote:
>> #!/usr/local/bin/perl
>>
>> use strict;
>> use warnings;
>>
>> my $var1 = 'whoopdee';
>> my $var2 = 'do';
>>
>> my %dispatch = (
>> y => \&yy($var1,$var2),
> this, actually, is not a code reference but a return value reference
> of the &yy(
Harry Putnam wrote:
#!/usr/local/bin/perl
use strict;
use warnings;
my $var1 = 'whoopdee';
my $var2 = 'do';
my %dispatch = (
y => \&yy($var1,$var2),
this, actually, is not a code reference but a return value reference of
the &yy($var1, $var2) subroutine call, executed right at the tim
A while ago I asked for an example of a dispatch table.
r...@i.frys.com was kind enough to post the example below.
After tinkering with it a while I think I got it working ok, but I
wondered when you are using the reference syntax \&... How do you
pass in variables? My test script posted below t
38 matches
Mail list logo