SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
[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 ....

Contenu connexe

Tendances

Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
diego_k
 
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
 

Tendances (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 )
 

En vedette

Classics
ClassicsClassics
Classics
Ninu
 
The butterfly_The flower
The butterfly_The flowerThe butterfly_The flower
The butterfly_The flower
Ninu
 

En vedette (20)

prova due
prova dueprova due
prova due
 
Drupal101
Drupal101Drupal101
Drupal101
 
Seize The Cloud
Seize The CloudSeize The Cloud
Seize The Cloud
 
Content Marketing Optimization - TopRank Marketing
Content Marketing Optimization - TopRank MarketingContent Marketing Optimization - TopRank Marketing
Content Marketing Optimization - TopRank Marketing
 
Classics
ClassicsClassics
Classics
 
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
 
Erlang with Regexp Perl And Port
Erlang with Regexp Perl And PortErlang with Regexp Perl And Port
Erlang with Regexp Perl And Port
 
prova tre
prova treprova tre
prova tre
 
Content Marketing Strategy - The Future is Bright for Web Content
Content Marketing Strategy - The Future is Bright for Web Content Content Marketing Strategy - The Future is Bright for Web Content
Content Marketing Strategy - The Future is Bright for Web Content
 
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
 
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
 
prova
provaprova
prova
 
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
 
The butterfly_The flower
The butterfly_The flowerThe butterfly_The flower
The butterfly_The flower
 
Optimize & Socialize for Better Business Blogging
Optimize & Socialize for Better Business BloggingOptimize & Socialize for Better Business Blogging
Optimize & Socialize for Better Business Blogging
 
aaa
aaaaaa
aaa
 
Web-Scale Discovery: Post Implementation
Web-Scale Discovery: Post ImplementationWeb-Scale Discovery: Post Implementation
Web-Scale Discovery: Post Implementation
 
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
 
Atom Pub
Atom PubAtom Pub
Atom Pub
 

Similaire à [Erlang LT] Regexp Perl And Port

Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
Kang-min Liu
 
PERL Unit 6 regular expression
PERL Unit 6 regular expressionPERL Unit 6 regular expression
PERL Unit 6 regular expression
Binsent Ribera
 
Barely Legal Xxx Perl Presentation
Barely Legal Xxx Perl PresentationBarely Legal Xxx Perl Presentation
Barely Legal Xxx Perl Presentation
Attila Balazs
 
WindowsユーザのためのはじめてのPerlプログラミング
WindowsユーザのためのはじめてのPerlプログラミングWindowsユーザのためのはじめてのPerlプログラミング
WindowsユーザのためのはじめてのPerlプログラミング
Yosuke HASEGAWA
 
Perl Xpath Lightning Talk
Perl Xpath Lightning TalkPerl Xpath Lightning Talk
Perl Xpath Lightning Talk
ddn123456
 
Ruby 程式語言簡介
Ruby 程式語言簡介Ruby 程式語言簡介
Ruby 程式語言簡介
Wen-Tien Chang
 
Os Fetterupdated
Os FetterupdatedOs Fetterupdated
Os Fetterupdated
oscon2007
 

Similaire à [Erlang LT] 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
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
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
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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, ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 

[Erlang LT] 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 ....