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

From: "io(dot)sys" <io(dot)sys(at)post(dot)cz>
To: Cédric Godin <cedric(dot)godin(at)skynet(dot)be>, pgsql-novice(at)postgresql(dot)org
Subject: Re: syntax error in plperl wrapper for Perl regex replace.
Date: 2018-08-31 04:06:32
Message-ID: 20180831060632.50f088e3@aps.gogo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)godin(at)skynet(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Rossi, Maria 2018-09-10 14:45:38 md5 and trust and pg_hba.conf
Previous Message Cédric Godin 2018-08-30 09:20:49 Re: syntax error in plperl wrapper for Perl regex replace.