syntax error in plperl wrapper for Perl regex replace.

Поиск
Список
Период
Сортировка
От io.sys
Тема syntax error in plperl wrapper for Perl regex replace.
Дата
Msg-id 20180823192005.639d4531@aps.gogo
обсуждение исходный текст
Список pgsql-novice
Hi,

I am trying to create a simple wrapper to use Perl regexp replace capabilites, which
supports \L (aka "lowercase from here on") in a replacement-strings, not available in
postgre native regexp functions.

Based on this article:
https://www.anchor.com.au/blog/2013/09/extending-postgresql-high-level-languages-cats/
I copy-pasted the function code with a little adjustment, leading to:

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

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

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

When running the above code, I get a syntax error in the line "s/..".

When I remove this line, the function compiles, but (of course) does not do anything
usefull.

So, what is wrong with line:
    s/$_[1]/$_[2]/$_[3];

Thank in advance for reply.

R.Golis, Prague.


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

Предыдущее
От: Mike Dewhirst
Дата:
Сообщение: Thank you [Was: Switching from 9.1 to 9.5 on Ubuntu 16.04]
Следующее
От: "io.sys"
Дата:
Сообщение: Re: syntax error in plperl wrapper for Perl regex replace.