Re: perlsub

From: Martin_vi_Lange(at)t-online(dot)de (Martin Lange)
To: Nabil Sayegh <postgresql(at)e-trolley(dot)de>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: perlsub
Date: 2003-10-05 13:03:17
Message-ID: 1645556986.20031005150317@t-online.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello Nabil,

you worte at 2003-10-04T01:29:00:

> perlsub:
> -----------------------------------------------
> CREATE FUNCTION perlsub(text, text, text) RETURNS text AS '
> my ($data, $pat, $repl) = @_;
> $data =~ s/$pat/$repl/;
> return $data
> ' LANGUAGE 'plperl';
> -----------------------------------------------

> SELECT perlsub('a=b','([^=]+)=(.+)','key:$1;val:$2');

> Any idea ? Just a matter of quoting ?

What I understand: You want to split some data into a pair of key
and value.

So, just do that:

($key, $val) = split(/=/, $data);

HTH.

cya :-)
Martin "vi"

In response to

  • perlsub at 2003-10-03 23:29:00 from Nabil Sayegh

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Nabil Sayegh 2003-10-05 16:53:04 Re: perlsub
Previous Message Anshuman Kanwar 2003-10-04 19:22:26 Copy table structure