Re: perlsub

Поиск
Список
Период
Сортировка
От Jeff Eckermann
Тема Re: perlsub
Дата
Msg-id 20031007221644.5233.qmail@web20802.mail.yahoo.com
обсуждение исходный текст
Ответ на Re: perlsub  (Oliver Elphick <olly@lfix.co.uk>)
Список pgsql-novice
Ok, using plperlu:

jeck=# select s('fred','(fr)(ed)', '$1');
 s
----
 fr
(1 row)

jeck=# select s('fred','(fr)(ed)', '$2');
 s
----
 ed
(1 row)

jeck=# select s('fred','(fr)(ed)', '$2 $1');
ERROR:  plperl: error from function: syntax error at
(eval 7) line 2, near "$2 $1
"

jeck=# select s('fred','(fr)(ed)', '$2." ".$1');
   s
-------
 ed fr
(1 row)

So, the string to be evaluated must meet normal perl
syntactic rules for an expression.

The example you gave worked fine for me from the
command line because I was typing the "$2 $1" directly
into the regex, so one interpolation did the job.  In
the function the first interpolation placed the
argument string into the regex, not the value of the
variable, so the eval (s/.../.../ee) is needed to get
the value.

Hmm, maybe this was off-topic after all ;-)

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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

Предыдущее
От: Jeff Eckermann
Дата:
Сообщение: Re: perlsub
Следующее
От: David Rickard
Дата:
Сообщение: Dropping Databases