in reply to Perl regex to POSIX
A different approach would be to use Perl as a server-side language on Postgres. This page tells you how: http://www.oreillynet.com/pub/a/databases/2005/11/10/using-perl-in-postgresql.html
Their example is:
A Simple Examplepostgres$ createlang plperlu mydb
The easy way to show how to use PL/Perl is to create a very simple function; one that would be a lot harder to do otherwise. Suppose that you want to test if a given piece of text is a palindrome (a word that reads the same backwards as forwards), disregarding white space and the case of the letters. Here's a piece of SQL to define the function:
Given this function, you can write SQL like:create function palindrome(text) returns boolean language plperl immutable as ' my $arg = shift; my ($canonical = lc $arg) =~ s/\s+//g; return ($canonical eq reverse $canonical) ? "true" : "false"; ';
select name, region, country, population from towns where palindrome(name);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl regex to POSIX
by Sifmole (Chaplain) on Feb 07, 2007 at 02:21 UTC |