SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
[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 ....

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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 )
 

Andere mochten auch

Content Marketing Optimization - TopRank Marketing
Content Marketing Optimization - TopRank MarketingContent Marketing Optimization - TopRank Marketing
Content Marketing Optimization - TopRank MarketingTopRank Marketing Agency
 
Classics
ClassicsClassics
ClassicsNinu
 
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
 
Erlang with Regexp Perl And Port
Erlang with Regexp Perl And PortErlang with Regexp Perl And Port
Erlang with Regexp Perl And PortKeiichi Daiba
 
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 TopRank 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
 
#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
 
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
 
The butterfly_The flower
The butterfly_The flowerThe butterfly_The flower
The butterfly_The flowerNinu
 
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
 
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
 

Andere mochten auch (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
 

Ähnlich wie [Erlang LT] 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
 

Ähnlich wie [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
 

Kürzlich hochgeladen

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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 WorkerThousandEyes
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
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...apidays
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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 DevelopmentsTrustArc
 
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 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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...Drew Madelung
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Kürzlich hochgeladen (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

[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 ....