Re: syntax error in plperl wrapper for Perl regex replace.

Поиск
Список
Период
Сортировка
От io.sys
Тема Re: syntax error in plperl wrapper for Perl regex replace.
Дата
Msg-id 20180831060632.50f088e3@aps.gogo
обсуждение исходный текст
Ответ на syntax error in plperl wrapper for Perl regex replace.  ("io.sys" <io.sys@post.cz>)
Список pgsql-novice
Hi, Cédric.

Works! Thank you very much for the hint. Apparently, you are much more
experienced with Perl, than me.

Just for reference, my working function wrapper for Perl regexp replace
now looks like this:

----------
create or replace function perl_regexp_replace (text, text, text, text)
    returns text as $funcbody$

$_=$_[0];
eval "s/$_[1]/$_[2]/$_[3]";
return $_;

$funcbody$ language plperl immutable strict;
----------

Regards, Roman.


####################################
On Thu, 30 Aug 2018 11:20:49 +0200, Cédric Godin <cedric.godin@skynet.be>
wrote:

> Not being a perl expert either I think the problem lies in the regex
> line. You should eval it to have the expected result (and you can use
> your 4th parameter again then).
>
> eval "s/$_[1]/$_[2]/$_[3]";
>
> Regards, Cédric


В списке pgsql-novice по дате отправления:

Предыдущее
От: "io.sys"
Дата:
Сообщение: Re: syntax error in plperl wrapper for Perl regex replace.
Следующее
От: Fabio Pardi
Дата:
Сообщение: Re: md5 and trust and pg_hba.conf