SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
PL/PERL6
                  	
     	
  	
  @choplin


2010   7   31                               1
       	
  
            @choplin
            Bioinformatician	
  @Perl	
  -­‐>
            Web	
  &	
  DB	
  programmer@Server	
  Side	
  JavaScript
                         @
            okuno.a.aa             gmail.com



2010   7   31                                                            2
Perl

2010   7   31          3
LL   	
  Perl

2010   7   31                   4
2010   7   31   5
Usable	
  Perl6

                Rakudo	
  Star



2010   7   31                     6
?

                    7

2010   7   31           7
Perl6

                  •Smart	
  Match
                  •Junction
                  •etc.

2010   7   31                       8
!




2010   7   31       9
Cool!
2010   7    31                                                                                 10
2010   7   31   11
2010   7   31   12
10




2010   7   31   13
Perl7?

2010   7   31            14
2010   7   31   15
2010   7   31   16
17

2010   7   31        17
 =	
  


                     PL/Perl6

2010   7   31                   18
PL/Perl6

•PL	
  =	
  Procedural	
  Language
•PostgreSQL

•PostgreSQL                 Perl6

2010   7   31                        19
PL/Perl6
                •PL/Parrot	
  (by	
  Jonathan	
  "Duke"	
  
                Leto	
  	
  	
  	
  	
  	
  	
  	
  )	
  


                                             PL/Perl6
                                             PL/Parrot

                                             PostgreSQL
2010   7   31                                                 20
PL/Perl6                  LL

                                                         !
 $psql	
  -­‐C	
  “CREATE	
  FUNCTION	
  hello()	
  
 RETURNS	
  text	
  AS	
  $$	
  return	
  ‘hello’	
  $$	
  
 LANGUAGE	
  plperl6;	
  SELECT	
  hello();”
                        hello()
                        -­‐-­‐-­‐-­‐-­‐-­‐-­‐
                        hello
                                                         21

2010   7   31                                                 21
PL/Perl6

                Perl6	
  :	
  Object	
  Oriented
                                 +
       SQL	
  :	
  Functional	
  Oriented	
  ( )


2010   7   31                                      22
2010   7   31   23
 


2010   7   31          24
SQL


                      25

2010   7   31              25
Map



2010   7   31         26
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
Reduce



2010   7   31            28
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
2010   7   31   30
Perl6
           map	
  {factorial($_)},	
  @array;



           my	
  @tmp	
  =	
  map	
  {%count{$_}++},	
  (map	
  {($_	
  %	
  2)	
  ??	
  
           'even'	
  !!	
  'odd'},	
  @ary);
2010   7   31                                                                           31
32

2010   7   31        32
Rakudo	
  Star
                LWP::Simple
                  JSON::Tiny

                                 33

2010   7   31                         33
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
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
2010   7   31   36
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
$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
 


2010   7   31          39
!!?


                http://leto.net/dukeleto.pl/2010/06/rakudo-­‐perl-­‐6-­‐in-­‐your-­‐postgresql-­‐database.html

2010   7   31                                                                                                    40
Leto	
  ++,	
  Moritz	
  Lenz++




           http://groups.google.com/group/plparrot/browse_thread/thread/7aebe2e5a043e175



2010   7   31                                                                              41
    	
  

                PL/Perl6

2010   7   31                  42
SQL
2010   7   31   43
See	
  more	
  about	
  PL/Parrot	
  and	
  PL/Perl6
                     http://pl.parrot.org/
                     http://github.com/leto/plparrot
                     http://groups.google.com/group/plparrot



2010   7   31                                                          44

Contenu connexe

Tendances

Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
lestrrat
 
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POEYAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
Thiago Rondon
 

Tendances (20)

PHP Performance SfLive 2010
PHP Performance SfLive 2010PHP Performance SfLive 2010
PHP Performance SfLive 2010
 
Modern Getopt for Command Line Processing in Perl
Modern Getopt for Command Line Processing in PerlModern Getopt for Command Line Processing in Perl
Modern Getopt for Command Line Processing in Perl
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
Get your teeth into Plack
Get your teeth into PlackGet your teeth into Plack
Get your teeth into Plack
 
Findbin libs
Findbin libsFindbin libs
Findbin libs
 
Metadata-driven Testing
Metadata-driven TestingMetadata-driven Testing
Metadata-driven Testing
 
Zend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHPZend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHP
 
Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLite
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
Perl web app 테스트전략
Perl web app 테스트전략Perl web app 테스트전략
Perl web app 테스트전략
 
The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.
 
BASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic InterpolationBASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic Interpolation
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
 
2010 Smith Scripting101
2010 Smith Scripting1012010 Smith Scripting101
2010 Smith Scripting101
 
BSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationBSDM with BASH: Command Interpolation
BSDM with BASH: Command Interpolation
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
 
Git::Hooks
Git::HooksGit::Hooks
Git::Hooks
 
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POEYAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
 
Short Introduction To "perl -d"
Short Introduction To "perl -d"Short Introduction To "perl -d"
Short Introduction To "perl -d"
 

Similaire à 2010/7/31 LTの虎@LL Tiger

Old Oracle Versions
Old Oracle VersionsOld Oracle Versions
Old Oracle Versions
Jeffrey Kemp
 

Similaire à 2010/7/31 LTの虎@LL Tiger (20)

Introducing perl6
Introducing perl6Introducing perl6
Introducing perl6
 
Php 7 evolution
Php 7 evolutionPhp 7 evolution
Php 7 evolution
 
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP LimogesPHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
Apache pig
Apache pigApache pig
Apache pig
 
Plpgsql internals
Plpgsql internalsPlpgsql internals
Plpgsql internals
 
Tuga IT 2018 Summer Edition - The Future of C#
Tuga IT 2018 Summer Edition - The Future of C#Tuga IT 2018 Summer Edition - The Future of C#
Tuga IT 2018 Summer Edition - The Future of C#
 
Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)
 
Introduction to source{d} Engine and source{d} Lookout
Introduction to source{d} Engine and source{d} Lookout Introduction to source{d} Engine and source{d} Lookout
Introduction to source{d} Engine and source{d} Lookout
 
The bytecode hocus pocus - JavaOne 2016
The bytecode hocus pocus - JavaOne 2016The bytecode hocus pocus - JavaOne 2016
The bytecode hocus pocus - JavaOne 2016
 
Having Fun Programming!
Having Fun Programming!Having Fun Programming!
Having Fun Programming!
 
Full Stack Clojure
Full Stack ClojureFull Stack Clojure
Full Stack Clojure
 
Drupal 8 multilingual APIs
Drupal 8 multilingual APIsDrupal 8 multilingual APIs
Drupal 8 multilingual APIs
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
 
The bytecode mumbo-jumbo
The bytecode mumbo-jumboThe bytecode mumbo-jumbo
The bytecode mumbo-jumbo
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from inside
 
Python and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunPython and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihun
 
Perl 101
Perl 101Perl 101
Perl 101
 
Old Oracle Versions
Old Oracle VersionsOld Oracle Versions
Old Oracle Versions
 

Plus de Akihiro Okuno (8)

qpstudy 2013.07 NoSQL
qpstudy 2013.07 NoSQLqpstudy 2013.07 NoSQL
qpstudy 2013.07 NoSQL
 
カジュアルにソースコードリーディング
カジュアルにソースコードリーディングカジュアルにソースコードリーディング
カジュアルにソースコードリーディング
 
SQLの話
SQLの話SQLの話
SQLの話
 
Write parser with fun!
Write parser with fun!Write parser with fun!
Write parser with fun!
 
groonga with PostgreSQL
groonga with PostgreSQLgroonga with PostgreSQL
groonga with PostgreSQL
 
Start Vim script @Ujihisa.vim 2011/11/19
Start Vim script @Ujihisa.vim 2011/11/19Start Vim script @Ujihisa.vim 2011/11/19
Start Vim script @Ujihisa.vim 2011/11/19
 
Mongo db勉強会20110730
Mongo db勉強会20110730Mongo db勉強会20110730
Mongo db勉強会20110730
 
第一回Mongo dbソースコードリーディング 20110628
第一回Mongo dbソースコードリーディング 20110628第一回Mongo dbソースコードリーディング 20110628
第一回Mongo dbソースコードリーディング 20110628
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

2010/7/31 LTの虎@LL Tiger

  • 1. PL/PERL6      @choplin 2010 7 31 1
  • 2.    @choplin  Bioinformatician  @Perl  -­‐>  Web  &  DB  programmer@Server  Side  JavaScript  @  okuno.a.aa gmail.com 2010 7 31 2
  • 3. Perl 2010 7 31 3
  • 4. LL  Perl 2010 7 31 4
  • 5. 2010 7 31 5
  • 6. Usable  Perl6 Rakudo  Star 2010 7 31 6
  • 7. ? 7 2010 7 31 7
  • 8. Perl6 •Smart  Match •Junction •etc. 2010 7 31 8
  • 9. ! 2010 7 31 9
  • 10. Cool! 2010 7 31 10
  • 11. 2010 7 31 11
  • 12. 2010 7 31 12
  • 13. 10 2010 7 31 13
  • 14. Perl7? 2010 7 31 14
  • 15. 2010 7 31 15
  • 16. 2010 7 31 16
  • 17. 17 2010 7 31 17
  • 18.  =   PL/Perl6 2010 7 31 18
  • 19. PL/Perl6 •PL  =  Procedural  Language •PostgreSQL •PostgreSQL Perl6 2010 7 31 19
  • 20. PL/Perl6 •PL/Parrot  (by  Jonathan  "Duke"   Leto                )   PL/Perl6 PL/Parrot PostgreSQL 2010 7 31 20
  • 21. PL/Perl6 LL ! $psql  -­‐C  “CREATE  FUNCTION  hello()   RETURNS  text  AS  $$  return  ‘hello’  $$   LANGUAGE  plperl6;  SELECT  hello();” hello() -­‐-­‐-­‐-­‐-­‐-­‐-­‐ hello 21 2010 7 31 21
  • 22. PL/Perl6 Perl6  :  Object  Oriented + SQL  :  Functional  Oriented  ( ) 2010 7 31 22
  • 23. 2010 7 31 23
  • 24.   2010 7 31 24
  • 25. SQL 25 2010 7 31 25
  • 26. Map 2010 7 31 26
  • 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
  • 28. Reduce 2010 7 31 28
  • 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
  • 30. 2010 7 31 30
  • 31. Perl6 map  {factorial($_)},  @array; my  @tmp  =  map  {%count{$_}++},  (map  {($_  %  2)  ??   'even'  !!  'odd'},  @ary); 2010 7 31 31
  • 32. 32 2010 7 31 32
  • 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
  • 36. 2010 7 31 36
  • 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
  • 39.   2010 7 31 39
  • 40. !!? http://leto.net/dukeleto.pl/2010/06/rakudo-­‐perl-­‐6-­‐in-­‐your-­‐postgresql-­‐database.html 2010 7 31 40
  • 41. Leto  ++,  Moritz  Lenz++ http://groups.google.com/group/plparrot/browse_thread/thread/7aebe2e5a043e175 2010 7 31 41
  • 42.     PL/Perl6 2010 7 31 42
  • 43. SQL 2010 7 31 43
  • 44. See  more  about  PL/Parrot  and  PL/Perl6 http://pl.parrot.org/ http://github.com/leto/plparrot http://groups.google.com/group/plparrot 2010 7 31 44