Re: PlPerl scope issue
От | Andy Colson |
---|---|
Тема | Re: PlPerl scope issue |
Дата | |
Msg-id | 4B2962C4.4050804@squeakycode.net обсуждение исходный текст |
Ответ на | Re: PlPerl scope issue ("Peter" <peter@greatnowhere.com>) |
Список | pgsql-general |
On 12/16/2009 3:15 PM, 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. > > I have since resolved the issue by using 'local' scope, but it still beats > me why variables are not seen in inner subroutines. The same code works in > plain Perl on the same machine as Postgres, and it also works on second > 8.4.1 Postgres/FreeBSD box. Glitch Ubuntu Karmic debs perhaps? > > Sorry for top-posting... me is being forced to use stooped Outlook... > > Peter > Becuase (borrowing Martijn's code), you have this: my $test=shift; test(); return $test; sub test { print "X=".$test."\n"; } And PG is wrapping your entire source code in a sub, so... it sees: sub pg-auto-wrap { my $test=shift; test(); return $test; sub test { print "X=".$test."\n"; } } I'd guess you dont want 'local'. You probably want 'our'. I have the same problems in mod_perl. -Andy
В списке pgsql-general по дате отправления: