| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | "Duncan Adams (DNS)" <duncan(dot)adams(at)vcontractor(dot)co(dot)za> |
| Cc: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: pl/perl Documentation |
| Date: | 2002-05-22 14:24:48 |
| Message-ID: | 24004.1022077488@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
"Duncan Adams (DNS)" <duncan(dot)adams(at)vcontractor(dot)co(dot)za> writes:
> CREATE or REPLACE FUNCTION remspace(TEXT) RETURN TEXT
> AS '
> @_ =~ s/\s*//;
> return @_'
> LANGUAGE 'plperl';
I'm not much of a Perl hacker, but even I can see that this is not good
Perl. You need a semicolon to finish the return statement, and I think
you want to manipulate the first element of the @_ array, not the whole
array. So something like
CREATE or REPLACE FUNCTION remspace(TEXT) RETURN TEXT AS '
$_[0] =~ s/\s*//;
return $_[0];
' LANGUAGE 'plperl';
would probably do what you want.
I'd recommend getting hold of a book about Perl.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Rasmus Mohr | 2002-05-22 14:29:50 | Re: optimising data load |
| Previous Message | Tom Sheehan | 2002-05-22 14:19:31 | Re: Better way to bulk-load millions of CSV records into postgres? |