Обсуждение: what's wrong with my plperl function?

Поиск
Список
Период
Сортировка

what's wrong with my plperl function?

От
Bruno Boettcher
Дата:
Hello,

i am still at the same stage.... thanks to Oliver Elphick the plperl
module is working, as a stand alone per program the thing works (sole
difference, i use $toparse =  shift; instead of the $toparse =  $_[0];
in the sql-function....

here's the thing:
CREATE FUNCTION cleanFromSep(text,text) RETURNS int4    AS '       $toparse =  $_[0];       $work =  $_[0];
$format = $_[1];       print "first step $work\n";       $work =~s/\.//g;       print "second step $work\n";
$work=~s/\,//g;       print "final step $work\n";       $work *= 100       if($format =~/,\d{2}$/ &&
!($toparse=~/,\d{2}$/));      print "eventual mult step $work\n";       return $work;       ' LANGUAGE 'plperl';
 

the perl script gives:
./test.pl 1.000.000 999.999.999,99
first step 1.000.000
second step 1000000
final step 1000000
eventual mult step 100000000

and the SQL function:
select cleanFromSep('1.000.000','999.999.999,99');cleanfromsep --------------            0
(1 row)

so what am i doing wrong? besides how can i output debug stuff from the
perl script? print manifestingly doesn't work...


-- 
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
===============================================================
the total amount of intelligence on earth is constant.
human population is growing....


Re: what's wrong with my plperl function?

От
Tom Lane
Дата:
Bruno Boettcher <bboett@erm1.u-strasbg.fr> writes:
> so what am i doing wrong?

I'm confused too...

> besides how can i output debug stuff from the
> perl script? print manifestingly doesn't work...

I don't see why print wouldn't work.  Realize however that it will
go to the postmaster's stdout, so you'd better not have started the
postmaster with -S, and you should have redirected the postmaster's
stdout/stderr into a log file someplace.

You might have better luck printing to stderr, BTW ... that should
get flushed to the disk file once per line, whereas Perl might think
it only needs to flush stdout once per block.

Also, it looks like plperl supports elog(NOTICE, "text") and
elog(ERROR, "text"), though I haven't tried 'em.
        regards, tom lane


Re: what's wrong with my plperl function?

От
Bruno Boettcher
Дата:
On Wed, Dec 06, 2000 at 10:54:58AM -0500, Tom Lane wrote:
> I'm confused too...
:D

> I don't see why print wouldn't work.  Realize however that it will
> go to the postmaster's stdout, so you'd better not have started the
yep found it in the log....

> Also, it looks like plperl supports elog(NOTICE, "text") and
> elog(ERROR, "text"), though I haven't tried 'em.
that does it!
but another strange thing:

first step 1.000.000
second step 
final step 

code was 
print "first step $work\n";
$work =~s/\.//g;
print "second step $work\n";
$work =~s/\,//g;
print "final step $work\n";

seems the =~ isn't supported..... ? :(
tryed even this:  $_ = $work;  s/\.//g;   $work =$_; 

but same.... this is basic perl.... at least i thought so...


-- 
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
===============================================================
the total amount of intelligence on earth is constant.
human population is growing....


Re: what's wrong with my plperl function?

От
Bruno Boettcher
Дата:
On Wed, Dec 06, 2000 at 05:52:13PM +0100, Bruno Boettcher wrote:
> $work =~s/\.//g;
ehm yeah stupid me... think i even read it somewhere in the docu....
should be $work =~ s/\\.//g;
:(
at least it works now...


-- 
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
===============================================================
the total amount of intelligence on earth is constant.
human population is growing....