| From: | Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com> | 
|---|---|
| To: | Nabil Sayegh <postgresql(at)e-trolley(dot)de> | 
| Cc: | pgsql-novice(at)postgresql(dot)org | 
| Subject: | Re: perlsub | 
| Date: | 2003-10-06 14:17:01 | 
| Message-ID: | 20031006141701.61967.qmail@web20808.mail.yahoo.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-novice | 
(sound of dusting off of perl)
Capturing using $1 etc definitely does work in pl/perl
functions: I have used that plenty.
Strictly speaking, backreferences in
search-and-replace are signified by \1, \2 etc (not
$1, $2).  In the body of a PostgreSQL function those
backslashes would need to be escaped: my preference is
to double them (\\1, \\2).  This does not seem to
relate to your example though.
Arbitrary search-and-replace works fine for me, in a
simple case:
create function s(text, text, text) returns text as '
$_[0] =~ s/$_[1]/$_[2]/;
return $_[0];
' language 'plperl';
Perhaps if you could post a "real" example, you might
get more useful help.
--- Nabil Sayegh <postgresql(at)e-trolley(dot)de> wrote:
> Thanks for your answer.
> 
> The snippet was just an example.
> What I really want(ed) to do was arbitrary regex
> search/replace.
> 
> Martin Lange wrote:
> 
> > 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.
> 
> -- 
>   e-Trolley Sayegh & John, Nabil Sayegh
>   Tel.: 0700 etrolley /// 0700 38765539
>   Fax.: +49 69 8299381-8
>   PGP : http://www.e-trolley.de
> 
> 
> ---------------------------(end of
> broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose
> an index scan if your
>       joining column's datatypes do not match
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nabil Sayegh | 2003-10-06 14:46:19 | Re: perlsub | 
| Previous Message | sibusiso xolo | 2003-10-06 14:03:53 | problems restoring 7.2.1 databases |