Search Postgresql Archives

Re: PlPerl scope issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux