Re: PlPerl scope issue - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: PlPerl scope issue
Date
Msg-id 20091216220607.GE17751@svana.org
Whole thread Raw
In response to Re: PlPerl scope issue  ("Peter" <peter@greatnowhere.com>)
List 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.

Attachment

pgsql-general by date:

Previous
From: Greg Smith
Date:
Subject: Re: Justifying a PG over MySQL approach to a project
Next
From: Tim Hart
Date:
Subject: Re: make check fails on OS X 10.6.2