27. CREATE
FUNCTION
perl_array()
RETURNS
text
AS
$$
my
$ary
=
"1t2t3t4";
return
$ary.join('t');
$$
LANGUAGE
plperl6;
CREATE
FUNCTION
perl_factorial(integer)
RETURNS
integer
AS
$$
my
$ret
=
1;
for
1..@_[0]
{
$ret
*=
$_
}
return
$ret;
$$
LANGUAGE
plperl6;
SELECT
perl_factorial(elem)
FROM
(
SELECT
CAST(unnest(string_to_array(perl_array(),
't'))
AS
integer
AS
elem
)array
;
2010 7 31 27
29. CREATE
FUNCTION
perl_array()
RETURNS
text
AS
$$
my
$ary
=
"1t2t3t4";
return
$ary.join('t');
$$
LANGUAGE
plperl6;
SELECT
CASE
mod(col,
2)
WHEN
0
THEN
'odd'
WHEN
1
THEN
'even'
END
AS
mod
,count(col)
FROM
(
SELECT
CAST(unnest(string_to_array(perl_array(),
't'))
AS
integer)
AS
elem
)array
GROUP
BY
mod
2010 7 31 29
33. Rakudo
Star
LWP::Simple
JSON::Tiny
33
2010 7 31 33
34. CREATE
FUNCTION
twitter_public_timeline()
RETURNS
text
AS
$$
use
LWP::Simple;
use
JSON::Tiny;
my
$url
=
'http://api.twitter.com/1/statuses/
public_timeline.json';
my
$lwp
=
LWP::Simple.new;
my
$content
=
$lwp.get($url);
my
$json
=
from-‐json($content);
my
@ary;
for
$json.values
-‐>
$post{
@ary.push($post<text>)
}
return
@ary.join("t");
$$
LANGUAGE
plperl6;
SELECT
twitter_public_timeline();
2010 7 31 34
35. psql:twitter.sql:31:
server
closed
the
connection
unexpectedly
This
probably
means
he
server
terminated
abnormally
before
of
while
processing
the
request.
psql:twiter.sql:31:
connection
to
server
was
lost
?
35
2010 7 31 35
37. Perl5
CREATE
FUNCTION
twitter_public_timeline()
RETURNS
text
AS
$$
use
LWP::Simple;
use
JSON;
my
$url
=
'http://api.twitter.com/1/statuses/
public_timeline.json';
my
$content
=
get($url);
my
$json
=
decode_json($content);
my
@ary;
for
my
$post
(@{
$json
}){push(@ary,
$post-‐>{text})}
return
join
"t",
@ary;
$$
LANGUAGE
plperlu;
SELECT
twitter_public_timeline;
2010 7 31 37
38. $psql -f twitter_perl5.sql
twitter_public_timeline
!
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
putzz pensei qe era minaa :X (@piconn live on http://twitcam.com/1ezjg)
Ok el #TL esta demasiado X.. chao pescao!
(/_;)
Royal Links in Vegas Simulates British Open Venues http://bit.ly/bBJcIT
Calling my sister & i'm scared.
"a necessidade de se manter um histórico é a de poder reler, ver
erros e corrigi-los...e pq é engraçado reler as lezeras de sempre ^^"
será que isso é a esperança do meu curso de fotografia indo embora? ):
alhamdulillah uang 50 rb dr gd. Q gue yg ilang entah berantah,skr d
ganti berkali lipat dr gd. Q jg,terima kasih Allah :)
RT @amochoco:
Jahatttt gak boleh ijin...hikss
How To Make Money Blogging... Big Money http://bit.ly/aIkMuu
3
!!!
♪ RT @9_kumi_3:
@NaluHawaii ♪
kasih gue kelinci dong..
sinceramente, eu acho que eu vou chorar quando Hannah Montana
acabar... eu sou muuuuuito apaixonada por essa série...
Photo: manhattan skyline http://tumblr.com/xxwel6auo
Shit playin cards drinkin what's up???!!
Perl5 !
mission accomplished.!!
(20 rows)
38
2010 7 31 38