Re: PlPerl scope issue

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Peter <peter(at)greatnowhere(dot)com>
Cc: 'Tim Bunce' <Tim(dot)Bunce(at)pobox(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: PlPerl scope issue
Date: 2009-12-16 22:06:07
Message-ID: 20091216220607.GE17751@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tim Hart 2009-12-16 22:24:14 Re: make check fails on OS X 10.6.2
Previous Message Greg Smith 2009-12-16 21:53:58 Re: Justifying a PG over MySQL approach to a project