Re: syntax error in plperl wrapper for Perl regex replace. - Mailing list pgsql-novice

From io.sys
Subject Re: syntax error in plperl wrapper for Perl regex replace.
Date
Msg-id 20180831060632.50f088e3@aps.gogo
Whole thread Raw
In response to syntax error in plperl wrapper for Perl regex replace.  ("io.sys" <io.sys@post.cz>)
List 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 by date:

Previous
From: "io.sys"
Date:
Subject: Re: syntax error in plperl wrapper for Perl regex replace.
Next
From: Fabio Pardi
Date:
Subject: Re: md5 and trust and pg_hba.conf