Re: PlPerl scope issue

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: PlPerl scope issue
Дата
Msg-id 20091216220607.GE17751@svana.org
обсуждение исходный текст
Ответ на Re: PlPerl scope issue  ("Peter" <peter@greatnowhere.com>)
Список pgsql-general
On Wed, Dec 16, 2009 at 03:15:21PM -0600, Peter wrote:
> Hello Tim,
>
> Thanks for the reply! I'm still not sure why it's bad to have named
> subroutines. At any rate I cant use anon subs since we have a complicated
> reporting subsystem that relies on Perl formulas being eval-ed at runtime,
> and these refer to various subroutines.

Maybe the example below will clear things up for you. I don't
understand why you could use anon subs, since they're not a lot of
difference between "sub foo {}" and "$foo = sub {}" except the latter
doesn't have the problem you're running into.

sub main
{
    my $test=shift;
    test();
    return $test;
    sub test {
       print "X=".$test."\n";
    }
}
main(1);
main(2);

Output:
X=1
X=1

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Greg Smith
Дата:
Сообщение: Re: Justifying a PG over MySQL approach to a project
Следующее
От: Tim Hart
Дата:
Сообщение: Re: make check fails on OS X 10.6.2