Re: arrays as pl/perl input arguments [PATCH]
От | Alex Hunsaker |
---|---|
Тема | Re: arrays as pl/perl input arguments [PATCH] |
Дата | |
Msg-id | AANLkTim-ANJTH-4j1KrEC=3O_AVqjPCAZZitgmWY8buq@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: arrays as pl/perl input arguments [PATCH] (Andrew Dunstan <andrew@dunslane.net>) |
Список | pgsql-hackers |
On Wed, Jan 12, 2011 at 14:45, Andrew Dunstan <andrew@dunslane.net> wrote: > > What I was casting a bit of doubt on upthread was whether or not this would > work without possibly breaking some code, in possibly silent or obscure > ways. I can't see how it would break, unless we did it wrong... > If I'm wrong about that, then by all means let's use some perl Magic > (that's a technical term) to achieve this. IIRC Alex recently posted some > code that might be instructive about this. There might be a more gutsy way to do this so that 'ref' gives you back what you expected (would that be 'ARRAY' or 'SCALAR' ?), but there is a simple pure perl solution using overload: package PLPerl::ArgArray; use overload '""' => \&to_str; sub new { # note we bless an arrayref here instead of the usual hashref so # you can use this 'object' as a normal array return bless([@_],... ); } sub to_str { my $self = shift; # yeah this is not right not correct :P # we could also die here with something like "You are tryingto use an Array as a string" or whatever return join(',', map { '{'. $_ .'}' } @{$self}); } ---------
В списке pgsql-hackers по дате отправления: