kotoko has asked for the wisdom of the Perl Monks concerning the following question:
It gives me a undefined subroutine &main:: called at ... error. Anybody can give me some advice?$a = sub {return @_[0]}; (yes I know....) $b = sub {return @_[0]+1}; .... some code ..... if (something) $i = $a; else $i = $b; &lala ($i); sub lala{ my $i = $_[0]; $res = &{$i}($number) ; #have also tried $res = $i->($number) with the same result }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using reference to subroutine
by Joost (Canon) on Apr 04, 2007 at 18:44 UTC | |
|
Re: using reference to subroutine
by shmem (Chancellor) on Apr 04, 2007 at 18:52 UTC | |
by kotoko (Novice) on Apr 05, 2007 at 13:31 UTC | |
by cdarke (Prior) on Apr 05, 2007 at 15:05 UTC | |
by blazar (Canon) on Apr 06, 2007 at 09:30 UTC | |
by kotoko (Novice) on Apr 05, 2007 at 17:00 UTC | |
by blazar (Canon) on Apr 06, 2007 at 09:37 UTC | |
by kotoko (Novice) on Apr 05, 2007 at 13:03 UTC | |
|
Re: using reference to subroutine (assume)
by tye (Sage) on Apr 04, 2007 at 18:34 UTC | |
by kotoko (Novice) on Apr 05, 2007 at 13:45 UTC | |
|
Re: using reference to subroutine
by perrin (Chancellor) on Apr 04, 2007 at 18:50 UTC | |
by kotoko (Novice) on Apr 05, 2007 at 12:21 UTC | |
by blazar (Canon) on Apr 07, 2007 at 10:31 UTC |