SlideShare a Scribd company logo
1 of 19
Download to read offline
[LT] Regexp, Perl, and Port

          id:kdaiba
whoami

 id:kdaiba
 Erlang newbie
 Perl Monger
     Yokohama.pm
     Shibuya.pm
     Tokyo.pm
     Now, setting up quot;Japan Perl Associationquot;
         http://trac.endeworks.jp/trac/tpfj/wiki
 Infrastructure Engineer
Erlang supports unicode in R12B-5
Try to print utf-8

perl -e 'map{printf quot;%d,quot;,$_}(unpack quot;C*quot;,quot;寿quot;);print quot;nquot;;'
   229,175,191,

1> UniString = [229,175,191].
quot;寿quot;
2> io:format(quot;~p~nquot;,[UniString]).
quot;寿quot;
ok
3>

It's looks OK on mac's terminal. But ...
When you run this script...

#!/usr/local/bin/escript
main(_) ->
   Item0 = quot;寿quot;,
   Item1 = quot;寿限quot;,
   Item2 = quot;寿限無quot;,
   Item3 = [[229,175,191],[233,153,144],[231,132,161]],
   io:format(quot;~p~nquot;, [Item0]),
   io:format(quot;~p~nquot;, [Item1]),
   io:format(quot;~p~nquot;, [Item2]),
   [io:format(quot;~p~nquot;, [X]) || X <- Item3].
You'll get returns, like below

quot;寿quot;
[229,175,191,233,153,144]
[229,175,191,233,153,144,231,132,161]
quot;寿quot;
[233,153,144]
[231,132,161]
Do google

 There is a page,
    quot;Representing Unicode characters in Erlangquot;
    http://www.erlang.org/eeps/eep-0010.html
    It's a quot;Erlang Enhancement Proposals (EEPs)quot;, #10
 This proposal's STATUS
    http://www.erlang.org/eeps/
    Standards Track EEP
    Accepted proposal
    NOT quot;Proposal is implemented in OTP release R12B-5quot;
Can't I use utf-8 now ?

use Erlang::Port to see Unicode
I made a perl script to printout utf-8

#!/usr/local/bin/escript
main(_) ->
   perlsay:start(quot;./perlsay.plquot;),
   perlsay:say(quot;寿限無、寿限無、五劫の擦り切れ、海砂利水魚、水
行末、雲来末、風来末、食う寝る所に住む所、薮ら柑子のぶら柑子、
パイポ、パイポ、パイポのシューリンガン、シューリンガンのグーリンダ
イ、グーリンダイのポンポコピーのポンポコナーの長久命の長助quot;),
   perlsay:stop().
You'll get returns on STDERR

寿限無、寿限無、五劫の擦り切れ、海砂利水魚、水行末、雲来末、
風来末、食う寝る所に住む所、薮ら柑子のぶら柑子、パイポ、パイ
ポ、パイポのシューリンガン、シューリンガンのグーリンダイ、グーリン
ダイのポンポコピーのポンポコナーの長久命の長助
Easy erlang code and

-module(perlsay).
-export([say/1]).
-export([start/1, stop/0]).
-import(perlport, [call/2, stop/1]).

say(String) ->
 call([say, String], perlsay).

start(Script) ->
 perlport:start(Script, perlsay).

stop() ->
 perlport:stop(perlsay).
Spaghetti perl script (1/4)

#!/usr/local/bin/perl
package Erlang::Port::Say;
use strict;
use warnings;
use Erlang::Port;

caller or __PACKAGE__->main(@ARGV);
1;
Spaghetti perl code (2/4)

sub main {
  my $pkg = shift;
  Erlang::Port->new(
     sub {
       my $obj = shift;
       my $port = shift;
       my $ret = eval { _my_proc( $obj, $port ) };
       $ret = $port->_newTuple( [ $port->_newAtom('error') => $@, ] )
        if ($@);
       $ret;
     }
  )->loop();
}
Spagetti perl Script (3/4)

sub _my_proc {
  my $obj = shift;
  my $port = shift;
  if ( !UNIVERSAL::isa( $obj, 'ARRAY' ) ) {
      return $port->_newTuple( [ $port->_newAtom('badarg'), $obj ] );
  }
  my $key = _to_s( $obj->[0] );
  if ( !defined($key) || $key ne 'say' ) {
      return $port->_newTuple( [ $port->_newAtom('badarg'), $obj ] );
  }
  my $str = _to_s( $obj->[1] );
  if ( !defined($str) ) {
      return $port->_newTuple( [ $port->_newAtom('badarg'), $obj ] );
  }
  print STDERR $str, quot;nquot;;
  $str;
}
Spagetti Perl Script (4/4)

sub _to_s {
  my $obj = shift;
  if ( defined($obj) && !ref($obj) ) {
      $obj;
  }
  elsif ( $obj && ref($obj) eq 'ARRAY' && @$obj == 0 ) {
      quot;quot;;
  }
  elsif ( ref($obj) && UNIVERSAL::isa( $obj, 'Erlang::Atom' ) ) {
      $$obj;
  }
  elsif ( ref($obj) && UNIVERSAL::isa( $obj, 'Erlang::Binary' ) ) {
      $$obj;
  }
  else { undef; }
}
quot;song and dancequot; too long ?

      I'm sorry to be boring
You can use this code like this

#!/usr/local/bin/escript

main(_) ->
 perlre:start(quot;./perlre.plquot;),
 perlsay:start(quot;./perlsay.plquot;),
 F = perlre:match(quot;赤とんぼquot;,quot;(p{Hiragana}+)quot;),
 [perlsay:say(X) || X <- F],
 perlre:stop(),
 perlsay:stop().

# perlre.pl is a sample code of Erlang::Port
Finally, you get ...

とんぼ
Twist ending

  I need to check B12-R5
  Today I have bad feelings. So I download B12-R5. It shows,
      Eshell V5.6.5 (abort with ^G)
  But, when I check my mac's erl, it shows
      Eshell V5.6.4 (abort with ^G)
  I made a mumbo jumbo ....

More Related Content

What's hot

Joy of Six - Discover the Joy of Perl 6
Joy of Six - Discover the Joy of Perl 6Joy of Six - Discover the Joy of Perl 6
Joy of Six - Discover the Joy of Perl 6trexy
 
Maybe you do not know that ...
Maybe you do not know that ...Maybe you do not know that ...
Maybe you do not know that ...Viktor Turskyi
 
Nigel hamilton-megameet-2013
Nigel hamilton-megameet-2013Nigel hamilton-megameet-2013
Nigel hamilton-megameet-2013trexy
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101hendrikvb
 
JSUG - Scala Lightning Talk by Michael Greifeneder
JSUG - Scala Lightning Talk by Michael GreifenederJSUG - Scala Lightning Talk by Michael Greifeneder
JSUG - Scala Lightning Talk by Michael GreifenederChristoph Pickl
 
第1回PHP拡張勉強会
第1回PHP拡張勉強会第1回PHP拡張勉強会
第1回PHP拡張勉強会Ippei Ogiwara
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
Any event intro
Any event introAny event intro
Any event introqiang
 
Using the Command Line with Magento
Using the Command Line with MagentoUsing the Command Line with Magento
Using the Command Line with MagentoMatthew Haworth
 
Perl Sucks - and what to do about it
Perl Sucks - and what to do about itPerl Sucks - and what to do about it
Perl Sucks - and what to do about it2shortplanks
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojobpmedley
 
De 0 a 100 con Bash Shell Scripting y AWK
De 0 a 100 con Bash Shell Scripting y AWKDe 0 a 100 con Bash Shell Scripting y AWK
De 0 a 100 con Bash Shell Scripting y AWKAdolfo Sanz De Diego
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Joseph Scott
 

What's hot (20)

Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
Joy of Six - Discover the Joy of Perl 6
Joy of Six - Discover the Joy of Perl 6Joy of Six - Discover the Joy of Perl 6
Joy of Six - Discover the Joy of Perl 6
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
Iteration
IterationIteration
Iteration
 
Maybe you do not know that ...
Maybe you do not know that ...Maybe you do not know that ...
Maybe you do not know that ...
 
Nigel hamilton-megameet-2013
Nigel hamilton-megameet-2013Nigel hamilton-megameet-2013
Nigel hamilton-megameet-2013
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101
 
JSUG - Scala Lightning Talk by Michael Greifeneder
JSUG - Scala Lightning Talk by Michael GreifenederJSUG - Scala Lightning Talk by Michael Greifeneder
JSUG - Scala Lightning Talk by Michael Greifeneder
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
 
第1回PHP拡張勉強会
第1回PHP拡張勉強会第1回PHP拡張勉強会
第1回PHP拡張勉強会
 
Elixir on Containers
Elixir on ContainersElixir on Containers
Elixir on Containers
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Any event intro
Any event introAny event intro
Any event intro
 
Using the Command Line with Magento
Using the Command Line with MagentoUsing the Command Line with Magento
Using the Command Line with Magento
 
Perl Sucks - and what to do about it
Perl Sucks - and what to do about itPerl Sucks - and what to do about it
Perl Sucks - and what to do about it
 
Embedding perl
Embedding perlEmbedding perl
Embedding perl
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
 
De 0 a 100 con Bash Shell Scripting y AWK
De 0 a 100 con Bash Shell Scripting y AWKDe 0 a 100 con Bash Shell Scripting y AWK
De 0 a 100 con Bash Shell Scripting y AWK
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )
 

Viewers also liked

#Optimize Content & Customers - Search Congress Barcelona
#Optimize Content & Customers - Search Congress Barcelona#Optimize Content & Customers - Search Congress Barcelona
#Optimize Content & Customers - Search Congress BarcelonaTopRank Marketing Agency
 
Convergence: Social Media SEO Content Marketing SES Chicago 2011
Convergence: Social Media SEO Content Marketing SES Chicago 2011Convergence: Social Media SEO Content Marketing SES Chicago 2011
Convergence: Social Media SEO Content Marketing SES Chicago 2011TopRank Marketing Agency
 
Classics
ClassicsClassics
ClassicsNinu
 
Content Marketing Optimization - TopRank Marketing
Content Marketing Optimization - TopRank MarketingContent Marketing Optimization - TopRank Marketing
Content Marketing Optimization - TopRank MarketingTopRank Marketing Agency
 
Optimize & Socialize for Better Business Blogging
Optimize & Socialize for Better Business BloggingOptimize & Socialize for Better Business Blogging
Optimize & Socialize for Better Business BloggingTopRank Marketing Agency
 
Web-Scale Discovery: Post Implementation
Web-Scale Discovery: Post ImplementationWeb-Scale Discovery: Post Implementation
Web-Scale Discovery: Post ImplementationRachel Vacek
 
Create Demand and Influence with Co-Created Content for B2B Marketing
Create Demand and Influence with Co-Created Content for B2B MarketingCreate Demand and Influence with Co-Created Content for B2B Marketing
Create Demand and Influence with Co-Created Content for B2B MarketingTopRank Marketing Agency
 
Content Marketing - How to Optimize & Socialize for Better Performance
Content Marketing  - How to Optimize & Socialize for Better PerformanceContent Marketing  - How to Optimize & Socialize for Better Performance
Content Marketing - How to Optimize & Socialize for Better PerformanceTopRank Marketing Agency
 
[Erlang LT] Regexp Perl And Port
[Erlang LT] Regexp Perl And Port[Erlang LT] Regexp Perl And Port
[Erlang LT] Regexp Perl And PortKeiichi Daiba
 
Evolution of Public Relations Through Content Marketing - Congreso PRORP
Evolution of Public Relations Through Content Marketing - Congreso PRORP  Evolution of Public Relations Through Content Marketing - Congreso PRORP
Evolution of Public Relations Through Content Marketing - Congreso PRORP TopRank Marketing Agency
 
How to Win Friends and Influence the Influencers - TopRank Marketing
How to Win Friends and Influence the Influencers - TopRank MarketingHow to Win Friends and Influence the Influencers - TopRank Marketing
How to Win Friends and Influence the Influencers - TopRank MarketingTopRank Marketing Agency
 

Viewers also liked (20)

prova due
prova dueprova due
prova due
 
Optimized Blogging That Inspires Action
Optimized Blogging That Inspires ActionOptimized Blogging That Inspires Action
Optimized Blogging That Inspires Action
 
#Optimize Content & Customers - Search Congress Barcelona
#Optimize Content & Customers - Search Congress Barcelona#Optimize Content & Customers - Search Congress Barcelona
#Optimize Content & Customers - Search Congress Barcelona
 
Convergence: Social Media SEO Content Marketing SES Chicago 2011
Convergence: Social Media SEO Content Marketing SES Chicago 2011Convergence: Social Media SEO Content Marketing SES Chicago 2011
Convergence: Social Media SEO Content Marketing SES Chicago 2011
 
Classics
ClassicsClassics
Classics
 
Content Marketing Optimization - TopRank Marketing
Content Marketing Optimization - TopRank MarketingContent Marketing Optimization - TopRank Marketing
Content Marketing Optimization - TopRank Marketing
 
Amazon Ec2
Amazon Ec2Amazon Ec2
Amazon Ec2
 
Atom Pub
Atom PubAtom Pub
Atom Pub
 
aaa
aaaaaa
aaa
 
Seize The Cloud
Seize The CloudSeize The Cloud
Seize The Cloud
 
prova tre
prova treprova tre
prova tre
 
Drupal101
Drupal101Drupal101
Drupal101
 
Optimize & Socialize for Better Business Blogging
Optimize & Socialize for Better Business BloggingOptimize & Socialize for Better Business Blogging
Optimize & Socialize for Better Business Blogging
 
Web-Scale Discovery: Post Implementation
Web-Scale Discovery: Post ImplementationWeb-Scale Discovery: Post Implementation
Web-Scale Discovery: Post Implementation
 
Create Demand and Influence with Co-Created Content for B2B Marketing
Create Demand and Influence with Co-Created Content for B2B MarketingCreate Demand and Influence with Co-Created Content for B2B Marketing
Create Demand and Influence with Co-Created Content for B2B Marketing
 
Content Marketing - How to Optimize & Socialize for Better Performance
Content Marketing  - How to Optimize & Socialize for Better PerformanceContent Marketing  - How to Optimize & Socialize for Better Performance
Content Marketing - How to Optimize & Socialize for Better Performance
 
prova
provaprova
prova
 
[Erlang LT] Regexp Perl And Port
[Erlang LT] Regexp Perl And Port[Erlang LT] Regexp Perl And Port
[Erlang LT] Regexp Perl And Port
 
Evolution of Public Relations Through Content Marketing - Congreso PRORP
Evolution of Public Relations Through Content Marketing - Congreso PRORP  Evolution of Public Relations Through Content Marketing - Congreso PRORP
Evolution of Public Relations Through Content Marketing - Congreso PRORP
 
How to Win Friends and Influence the Influencers - TopRank Marketing
How to Win Friends and Influence the Influencers - TopRank MarketingHow to Win Friends and Influence the Influencers - TopRank Marketing
How to Win Friends and Influence the Influencers - TopRank Marketing
 

Similar to Erlang with Regexp Perl And Port

Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In PerlKang-min Liu
 
PERL Unit 6 regular expression
PERL Unit 6 regular expressionPERL Unit 6 regular expression
PERL Unit 6 regular expressionBinsent Ribera
 
Barely Legal Xxx Perl Presentation
Barely Legal Xxx Perl PresentationBarely Legal Xxx Perl Presentation
Barely Legal Xxx Perl PresentationAttila Balazs
 
WindowsユーザのためのはじめてのPerlプログラミング
WindowsユーザのためのはじめてのPerlプログラミングWindowsユーザのためのはじめてのPerlプログラミング
WindowsユーザのためのはじめてのPerlプログラミングYosuke HASEGAWA
 
IST 561 Session 3, Feb 9, 2009--XHMTL and CSS basics
IST 561 Session 3, Feb 9, 2009--XHMTL and CSS basicsIST 561 Session 3, Feb 9, 2009--XHMTL and CSS basics
IST 561 Session 3, Feb 9, 2009--XHMTL and CSS basicsD.A. Garofalo
 
Impacta - Show Day de Rails
Impacta - Show Day de RailsImpacta - Show Day de Rails
Impacta - Show Day de RailsFabio Akita
 
Perl Xpath Lightning Talk
Perl Xpath Lightning TalkPerl Xpath Lightning Talk
Perl Xpath Lightning Talkddn123456
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottO'Reilly Media
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning PerlDave Cross
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With PhpJeremy Coates
 
☣ ppencode ♨
☣ ppencode ♨☣ ppencode ♨
☣ ppencode ♨Audrey Tang
 
CGI With Object Oriented Perl
CGI With Object Oriented PerlCGI With Object Oriented Perl
CGI With Object Oriented PerlBunty Ray
 
Out with Regex, In with Tokens
Out with Regex, In with TokensOut with Regex, In with Tokens
Out with Regex, In with Tokensscoates
 
Ruby 程式語言簡介
Ruby 程式語言簡介Ruby 程式語言簡介
Ruby 程式語言簡介Wen-Tien Chang
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdatedoscon2007
 

Similar to Erlang with Regexp Perl And Port (20)

Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
PERL Unit 6 regular expression
PERL Unit 6 regular expressionPERL Unit 6 regular expression
PERL Unit 6 regular expression
 
Perl Presentation
Perl PresentationPerl Presentation
Perl Presentation
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Barely Legal Xxx Perl Presentation
Barely Legal Xxx Perl PresentationBarely Legal Xxx Perl Presentation
Barely Legal Xxx Perl Presentation
 
WindowsユーザのためのはじめてのPerlプログラミング
WindowsユーザのためのはじめてのPerlプログラミングWindowsユーザのためのはじめてのPerlプログラミング
WindowsユーザのためのはじめてのPerlプログラミング
 
IST 561 Session 3, Feb 9, 2009--XHMTL and CSS basics
IST 561 Session 3, Feb 9, 2009--XHMTL and CSS basicsIST 561 Session 3, Feb 9, 2009--XHMTL and CSS basics
IST 561 Session 3, Feb 9, 2009--XHMTL and CSS basics
 
Impacta - Show Day de Rails
Impacta - Show Day de RailsImpacta - Show Day de Rails
Impacta - Show Day de Rails
 
Perl Xpath Lightning Talk
Perl Xpath Lightning TalkPerl Xpath Lightning Talk
Perl Xpath Lightning Talk
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning Perl
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With Php
 
☣ ppencode ♨
☣ ppencode ♨☣ ppencode ♨
☣ ppencode ♨
 
Ae internals
Ae internalsAe internals
Ae internals
 
CGI With Object Oriented Perl
CGI With Object Oriented PerlCGI With Object Oriented Perl
CGI With Object Oriented Perl
 
Out with Regex, In with Tokens
Out with Regex, In with TokensOut with Regex, In with Tokens
Out with Regex, In with Tokens
 
Ruby 程式語言簡介
Ruby 程式語言簡介Ruby 程式語言簡介
Ruby 程式語言簡介
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdated
 
Nop2
Nop2Nop2
Nop2
 

Recently uploaded

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Erlang with Regexp Perl And Port

  • 1. [LT] Regexp, Perl, and Port id:kdaiba
  • 2. whoami id:kdaiba Erlang newbie Perl Monger Yokohama.pm Shibuya.pm Tokyo.pm Now, setting up quot;Japan Perl Associationquot; http://trac.endeworks.jp/trac/tpfj/wiki Infrastructure Engineer
  • 4. Try to print utf-8 perl -e 'map{printf quot;%d,quot;,$_}(unpack quot;C*quot;,quot;寿quot;);print quot;nquot;;' 229,175,191, 1> UniString = [229,175,191]. quot;寿quot; 2> io:format(quot;~p~nquot;,[UniString]). quot;寿quot; ok 3> It's looks OK on mac's terminal. But ...
  • 5. When you run this script... #!/usr/local/bin/escript main(_) -> Item0 = quot;寿quot;, Item1 = quot;寿限quot;, Item2 = quot;寿限無quot;, Item3 = [[229,175,191],[233,153,144],[231,132,161]], io:format(quot;~p~nquot;, [Item0]), io:format(quot;~p~nquot;, [Item1]), io:format(quot;~p~nquot;, [Item2]), [io:format(quot;~p~nquot;, [X]) || X <- Item3].
  • 6. You'll get returns, like below quot;寿quot; [229,175,191,233,153,144] [229,175,191,233,153,144,231,132,161] quot;寿quot; [233,153,144] [231,132,161]
  • 7. Do google There is a page, quot;Representing Unicode characters in Erlangquot; http://www.erlang.org/eeps/eep-0010.html It's a quot;Erlang Enhancement Proposals (EEPs)quot;, #10 This proposal's STATUS http://www.erlang.org/eeps/ Standards Track EEP Accepted proposal NOT quot;Proposal is implemented in OTP release R12B-5quot;
  • 8. Can't I use utf-8 now ? use Erlang::Port to see Unicode
  • 9. I made a perl script to printout utf-8 #!/usr/local/bin/escript main(_) -> perlsay:start(quot;./perlsay.plquot;), perlsay:say(quot;寿限無、寿限無、五劫の擦り切れ、海砂利水魚、水 行末、雲来末、風来末、食う寝る所に住む所、薮ら柑子のぶら柑子、 パイポ、パイポ、パイポのシューリンガン、シューリンガンのグーリンダ イ、グーリンダイのポンポコピーのポンポコナーの長久命の長助quot;), perlsay:stop().
  • 10. You'll get returns on STDERR 寿限無、寿限無、五劫の擦り切れ、海砂利水魚、水行末、雲来末、 風来末、食う寝る所に住む所、薮ら柑子のぶら柑子、パイポ、パイ ポ、パイポのシューリンガン、シューリンガンのグーリンダイ、グーリン ダイのポンポコピーのポンポコナーの長久命の長助
  • 11. Easy erlang code and -module(perlsay). -export([say/1]). -export([start/1, stop/0]). -import(perlport, [call/2, stop/1]). say(String) -> call([say, String], perlsay). start(Script) -> perlport:start(Script, perlsay). stop() -> perlport:stop(perlsay).
  • 12. Spaghetti perl script (1/4) #!/usr/local/bin/perl package Erlang::Port::Say; use strict; use warnings; use Erlang::Port; caller or __PACKAGE__->main(@ARGV); 1;
  • 13. Spaghetti perl code (2/4) sub main { my $pkg = shift; Erlang::Port->new( sub { my $obj = shift; my $port = shift; my $ret = eval { _my_proc( $obj, $port ) }; $ret = $port->_newTuple( [ $port->_newAtom('error') => $@, ] ) if ($@); $ret; } )->loop(); }
  • 14. Spagetti perl Script (3/4) sub _my_proc { my $obj = shift; my $port = shift; if ( !UNIVERSAL::isa( $obj, 'ARRAY' ) ) { return $port->_newTuple( [ $port->_newAtom('badarg'), $obj ] ); } my $key = _to_s( $obj->[0] ); if ( !defined($key) || $key ne 'say' ) { return $port->_newTuple( [ $port->_newAtom('badarg'), $obj ] ); } my $str = _to_s( $obj->[1] ); if ( !defined($str) ) { return $port->_newTuple( [ $port->_newAtom('badarg'), $obj ] ); } print STDERR $str, quot;nquot;; $str; }
  • 15. Spagetti Perl Script (4/4) sub _to_s { my $obj = shift; if ( defined($obj) && !ref($obj) ) { $obj; } elsif ( $obj && ref($obj) eq 'ARRAY' && @$obj == 0 ) { quot;quot;; } elsif ( ref($obj) && UNIVERSAL::isa( $obj, 'Erlang::Atom' ) ) { $$obj; } elsif ( ref($obj) && UNIVERSAL::isa( $obj, 'Erlang::Binary' ) ) { $$obj; } else { undef; } }
  • 16. quot;song and dancequot; too long ? I'm sorry to be boring
  • 17. You can use this code like this #!/usr/local/bin/escript main(_) -> perlre:start(quot;./perlre.plquot;), perlsay:start(quot;./perlsay.plquot;), F = perlre:match(quot;赤とんぼquot;,quot;(p{Hiragana}+)quot;), [perlsay:say(X) || X <- F], perlre:stop(), perlsay:stop(). # perlre.pl is a sample code of Erlang::Port
  • 18. Finally, you get ... とんぼ
  • 19. Twist ending I need to check B12-R5 Today I have bad feelings. So I download B12-R5. It shows, Eshell V5.6.5 (abort with ^G) But, when I check my mac's erl, it shows Eshell V5.6.4 (abort with ^G) I made a mumbo jumbo ....