From: | Christopher Murtagh <christopher(dot)murtagh(at)mcgill(dot)ca> |
---|---|
To: | "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com> |
Cc: | Doug McNaught <doug(at)mcnaught(dot)org>, postgres general <pgsql-general(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> |
Subject: | Re: pl/perl function life and variable scope - |
Date: | 2003-11-12 21:24:53 |
Message-ID: | 1068672289.2593.17.camel@mafalda.murtagh.name |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 2003-11-12 at 15:44, Joshua D. Drake wrote:
> Or in other words... code to "strict"
:-)
Yes, I do normally. I was simply running a test and came across this
and it caught me by surprise. For the record, my pl/perl function is
this:
CREATE OR REPLACE FUNCTION htdig(text, text)
RETURNS text[] AS '
my $SearchTerms = $_[0];
my $HtDigDB = $_[1];
my @Result = {};
my $Line = '''';
#open HTDIG, "/usr/local/htdig/bin/htsearch ''config=" . $HtDigDB . ";words=" . $SearchTerms . "'';matchesperpage=1000;";
open HTDIG, "/bin/cat /home/postgres/" . $SearchTerms . " |";
while(<HTDIG>) {
$Line = $_;
$Line =~ s/^h[^0-9]*//;
chomp($Line);
push @Result, $Line;
}
close HTDIG;
return qq/{/ . (join qq/,/, @Result) . qq/}/;
' LANGUAGE plperlu;
I started writing this in C and realized that this was going to be a
couple hundred lines of code - compared to the 23 lines in Perl,
including test lines. All this function needs to do is to take a pipe
from the htsearch and grab integers in the URL that it returns. Then
I'll write a pl/pgSQL wrapper that returns this array as a set.
Pretty sweet, and I couldn't have done it without the help of this list.
Thanks!
Cheers,
Chris
--
Christopher Murtagh
Enterprise Systems Administrator
ISR / Web Communications Group
McGill University
Montreal, Quebec
Canada
Tel.: (514) 398-3122
Fax: (514) 398-2017
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Sullivan | 2003-11-12 21:43:03 | Re: [HACKERS] Proposal for a cascaded master-slave replication system |
Previous Message | Bruno Wolff III | 2003-11-12 21:17:37 | Re: serial type vs. sequences |