## Acme::EyeDrops
### nz_tcoder
---
## インストール
ubuntuだとlibacme-eyedrops-perlでOK。
他は cpan からインストールできるはず。
---
## とりあえず動かす
hello.pl
```
print "hello world\n";
```
ex1.pl
```
use Acme::EyeDrops qw(sightly);
print sightly({Shape => 'camel',
SourceFile => 'hello.pl'});
```
---
## もっとアスキーアート
Regexを1にすると、アルファべットと数字は使わない
ex2.pl
```
use Acme::EyeDrops qw(sightly);
print sightly({Shape => 'camel',
SourceFile => 'hello.pl',
Regex => 1});
```
という情報があったが、
```
use re 'eval';
```
の一行が…
---
## もっとアスキーアート
cpanのEyeDropsのページのBUGSには
> If using Perl 5.18+, the generated file needs a leading "use re 'eval'" when a postive value for Regex is used.
>
ということで、Perl 5.18以降で動かすには、use の一行が出てしまう。
---
## もっとアスキーアート
ex3.pl
```
use Acme::EyeDrops qw(sightly);
print sightly({Shape => 'camel',
SourceFile => 'hello.pl',
Regex => 2});
```
とすれば、use 行は出ない。この出力を動かすには
```
-M"re 'eval'"
```
オプションを使えばよい。
---
## デモ
### ex1.pl
```
$ cat hello.pl
print "hello world\n";
$ cat ex1.pl
use Acme::EyeDrops qw(sightly);
print sightly({Shape => 'camel',
SourceFile => 'hello.pl'});
$ perl ex1.pl
1 shapes completed.
eval eval '"'.
('['^"\+").(
('[')^ ')').('`'|')').
('`'|'.'). ('['^'/').('{'^'['
).'\\'.'"' .('`'| '(').('`'|'%').('`'|
',').('`'|',').('`'| '/').('{'^'[').(('[')^
',').('`'|'/').("\["^ ')').('`'|',').('`'|'$'
).'\\'.'\\'.(('`')| '.').'\\'.'"'.';'.('!'^'+'
).'"';$:="\."^ '~';$~='@'|'(';$^=')'^'[';$/=
'`'|'.';$,='(' ^'}';$\='`'|'!';$:=')'^('}');$~=
'*'|'`';$^='+'^ '_';$/='&'|'@';$,='['&'~';$\=(',')^
'|';$:='.'^'~'; $~='@'|'(';$^=')'^'[';$/='`'|('.');$,=
'('^'}';$\='`'| '!';$:=')'^'}';$~='*'|'`';$^='+'^'_';$/=
'&'|'@';$,='[' &'~';$\=','^'|';$:='.'^'~';$~='@'|'(';$^=
')'^'[';$/='`' |'.';$,='('^'}';$\='`'|'!';$:=')'^"\}";$~=
'*'|'`';$^='+'^'_';$/='&'|'@';$,='['&'~';$\=','^'|';$:='.'
^'~';$~='@'|'(';$^=')'^'[';$/='`'|'.';$,='('^'}';$\='`'|'!'
;$:=')'^'}';$~='*'|'`';$^='+'^'_';$/='&'|'@';$,='['&'~';$\
=','^'|';$:='.'^'~';$~='@'|'(';$^=')'^'[';$/='`'|'.';$,='('
^'}';$\='`'|'!';$:=')'^'}';$~='*'|'`';$^='+'^'_';$/='&'|'@'
;$,='['&'~';$\=','^'|';$:='.'^'~';$~='@'|'(';$^=')'^'[';$/
='`'|'.';$,='('^'}';$\='`'|'!';$:=')'^'}';$~='*'|'`'; $^=
'+'^'_';$/='&'|'@';$,='['&'~';$\=','^'|';$:='.'^'~' ;$~
='@'|'(';$^=')'^'[';$/='`'|'.';$,='('^'}' ;$\='`'| '!'
;$:=')'^'}';$~='*'|'`';$^='+'^"\_";$/= '&'|'@' ;$,
='['& '~';$\=','^'|';$:='.'^"\~";$~= '@'|'(' ;$^
=')'^'[';$/='`'|'.';$,=('(')^ '}';$\= '`'
|'!';$:= ')'^'}';$~ ="\*"| '`';$^ =(
('+'))^ "\_";$/= ('&')| '@';$, =(
('['))& "\~";$\= "\,"^ "\|"; (
($:))= '.'^'~'; ($~) ='@'
|"\("; $^=(')')^ '['; ($/)
='`'| "\.";$,= '('^ '}';
($\)= '`'|'!' ;$:= ')'^
'}'; $~='*' |'`' ;$^=
'+'^ '_' ;$/= '&'|
'@'; $,= '[' &((
'~' )); $\= ','
^(( '|' )); $:=
'.' ^(( '~' ))
;( ($~))= ((
(( '@')) ))
|+ "\(";$^= ((
')' ))^+ "\["; $/
=(( '`'))| '.'; $,=
'('^ "\}";$\= '`' |'!'
;($:)= (')')^
"\}";$~= '*'|'`'
$ perl ex1.pl|perl
1 shapes completed.
hello world
$
```
---
## デモ
### ex2.pl
```
$ cat ex2.pl
use Acme::EyeDrops qw(sightly);
print sightly({Shape => 'camel',
SourceFile => 'hello.pl',
Regex => 1});
$ perl ex2.pl
1 shapes completed.
use re 'eval';
''=~('('.'?'
.'{'.( '`'|'%').("\["^
'-').('`'| '!').('`'|',').'"'
.('['^'+') .('['^ ')').('`'|')').('`'|
'.').('['^'/').('{'^ '[').'\\'.'"'.('`'|'('
).('`'|'%').('`'|',') .('`'|',').('`'|"\/").(
'{'^'[').('['^','). ('`'|'/').('['^')').("\`"|
',').('`'|'$') .'\\'.'\\'.('`'|'.').'\\'.'"'
.';'.('!'^'+') .'"'.'}'.')');$:='.'^'~';$~='@'|
'(';$^=')'^'['; $/='`'|'.';$,='('^'}';$\='`'|'!';$:
=')'^'}';$~='*' |'`';$^='+'^'_';$/='&'|'@';$,='['&'~';
$\=','^"\|";$:= '.'^'~';$~='@'|'(';$^=')'^'[';$/='`'|'.'
;$,='('^'}';$\ ='`'|'!';$:=')'^'}';$~='*'|'`';$^='+'^'_'
;$/='&'|'@';$, ='['&'~';$\=','^'|';$:='.'^'~';$~='@'|'(';
$^=')'^'[';$/='`'|'.';$,='('^'}';$\='`'|'!';$:=')'^'}';$~=
'*'|'`';$^='+'^'_';$/='&'|'@';$,='['&'~';$\=','^'|';$:='.'^
'~';$~='@'|'(';$^=')'^'[';$/='`'|'.';$,='('^'}';$\='`'|'!'
;$:=')'^'}';$~='*'|'`';$^='+'^'_';$/='&'|'@';$,='['&'~';$\=
','^'|';$:='.'^'~';$~='@'|'(';$^=')'^'[';$/='`'|'.';$,='('^
'}';$\='`'|'!';$:=')'^'}';$~='*'|'`';$^='+'^'_';$/='&'|'@'
;$,='['&'~';$\=','^'|';$:='.'^'~';$~='@'|'(';$^="\)"^ '['
;$/='`'|'.';$,='('^'}';$\='`'|'!';$:=')'^'}';$~='*' |((
'`'));$^='+'^'_';$/='&'|'@';$,='['&'~';$\ =','^'|' ;$:
='.'^'~';$~='@'|'(';$^=')'^'[';$/='`'| '.';$,= '('
^'}'; $\='`'|'!';$:=')'^'}';$~="\*"| '`';$^= '+'
^'_';$/='&'|'@';$,='['&'~';$\ =(',')^ '|'
;$:='.'^ '~';$~='@' |"\("; $^=')' ^+
'[';$/= '`'|'.'; $,='(' ^"\}"; $\
=('`')| "\!";$:= "\)"^ "\}"; (
($~))= '*'|'`'; ($^) ='+'
^"\_"; $/=('&')| '@'; ($,)
='['& "\~";$\= ','^ '|';
($:)= '.'^'~' ;$~= '@'|
'('; $^=')' ^'[' ;$/=
'`'| '.' ;$,= '('^
'}'; $\= '`' |((
'!' )); $:= ')'
^(( '}' )); $~=
'*' |(( '`' ))
;( ($^))= ((
(( '+')) ))
^+ "\_";$/= ((
'&' ))|+ "\@"; $,
=(( '['))& '~'; $\=
','^ "\|";$:= '.' ^'~'
;($~)= ('@')|
"\(";$^= ')'^'['
$ perl ex2.pl|perl
1 shapes completed.
hello world
$
```
---
## デモ
### ex3.pl
```
$ cat ex3.pl
use Acme::EyeDrops qw(sightly);
print sightly({Shape => 'camel',
SourceFile => 'hello.pl',
Regex => 2});
$ perl ex3.pl
1 shapes completed.
''=~('('.'?'
.'{'.( '`'|'%').("\["^
'-').('`'| '!').('`'|',').'"'
.('['^'+') .('['^ ')').('`'|')').('`'|
'.').('['^'/').('{'^ '[').'\\'.'"'.('`'|'('
).('`'|'%').('`'|',') .('`'|',').('`'|"\/").(
'{'^'[').('['^','). ('`'|'/').('['^')').("\`"|
',').('`'|'$') .'\\'.'\\'.('`'|'.').'\\'.'"'
.';'.('!'^'+') .'"'.'}'.')');$:='.'^'~';$~='@'|
'(';$^=')'^'['; $/='`'|'.';$,='('^'}';$\='`'|'!';$:
=')'^'}';$~='*' |'`';$^='+'^'_';$/='&'|'@';$,='['&'~';
$\=','^"\|";$:= '.'^'~';$~='@'|'(';$^=')'^'[';$/='`'|'.'
;$,='('^'}';$\ ='`'|'!';$:=')'^'}';$~='*'|'`';$^='+'^'_'
;$/='&'|'@';$, ='['&'~';$\=','^'|';$:='.'^'~';$~='@'|'(';
$^=')'^'[';$/='`'|'.';$,='('^'}';$\='`'|'!';$:=')'^'}';$~=
'*'|'`';$^='+'^'_';$/='&'|'@';$,='['&'~';$\=','^'|';$:='.'^
'~';$~='@'|'(';$^=')'^'[';$/='`'|'.';$,='('^'}';$\='`'|'!'
;$:=')'^'}';$~='*'|'`';$^='+'^'_';$/='&'|'@';$,='['&'~';$\=
','^'|';$:='.'^'~';$~='@'|'(';$^=')'^'[';$/='`'|'.';$,='('^
'}';$\='`'|'!';$:=')'^'}';$~='*'|'`';$^='+'^'_';$/='&'|'@'
;$,='['&'~';$\=','^'|';$:='.'^'~';$~='@'|'(';$^="\)"^ '['
;$/='`'|'.';$,='('^'}';$\='`'|'!';$:=')'^'}';$~='*' |((
'`'));$^='+'^'_';$/='&'|'@';$,='['&'~';$\ =','^'|' ;$:
='.'^'~';$~='@'|'(';$^=')'^'[';$/='`'| '.';$,= '('
^'}'; $\='`'|'!';$:=')'^'}';$~="\*"| '`';$^= '+'
^'_';$/='&'|'@';$,='['&'~';$\ =(',')^ '|'
;$:='.'^ '~';$~='@' |"\("; $^=')' ^+
'[';$/= '`'|'.'; $,='(' ^"\}"; $\
=('`')| "\!";$:= "\)"^ "\}"; (
($~))= '*'|'`'; ($^) ='+'
^"\_"; $/=('&')| '@'; ($,)
='['& "\~";$\= ','^ '|';
($:)= '.'^'~' ;$~= '@'|
'('; $^=')' ^'[' ;$/=
'`'| '.' ;$,= '('^
'}'; $\= '`' |((
'!' )); $:= ')'
^(( '}' )); $~=
'*' |(( '`' ))
;( ($^))= ((
(( '+')) ))
^+ "\_";$/= ((
'&' ))|+ "\@"; $,
=(( '['))& '~'; $\=
','^ "\|";$:= '.' ^'~'
;($~)= ('@')|
"\(";$^= ')'^'['
$ perl ex3.pl|perl -M're "eval"'
1 shapes completed.
hello world
$
```
---
## デモ
### hello worldいろいろ
ソースプログラムの表示のみです。
```
$ cat demo.pl
use Acme::EyeDrops qw(sightly);
print sightly({Shape => $ARGV[0],
SourceFile => 'hello.pl',
Regex => 2});
$ cat shapes.sh
for s in `cat shapes.txt`
do
perl demo.pl $s;
sleep 2;
clear;
done
$ cat shapes.txt
alien
alpaca
camel2
coffee
cricket
debian
eye
kangaroo
larry
map_japan
smiley
$
```
---
## eyeを例にして(準備 ex4.pl)
```
$ cat ex4.pl
use Acme::EyeDrops qw(sightly);
print sightly({Shape => 'eye',
SourceFile => 'hello.pl',
Regex => 2});
$ perl ex4.pl
1 shapes completed.
''=~('('.'?'.'{'
. ('`'|'%').('['^"\-").( (
( '`'))|'!').('`'|',').'"'.( (
( '['))^'+').('['^')').('`'|')') .
( '`'|'.').('['^'/').('{'^'[').''. (
( '\\')).'"'.('`'|'(').('`'|('%')).( (
( '`'))|',').('`'|',').('`'|('/')).( (
( '{'))^'[').('['^',').('`'|'/').('['^ (
( ')'))).('`'|',').('`'|'$').'\\'.'\\' .
( '`'|'.').'\\'.'"'.';'.('!'^'+').'"'. (
( '}')).')');$:='.'^'~';$~='@'|'(';$^= (
( ')'))^'[';$/='`'|'.';$,='('^"\}";$\= (
( '`'))|'!';$:=')'^'}';$~='*'|'`';$^ =
( '+')^'_';$/='&'|'@';$,='['&'~';$\= (
( ','))^'|';$:='.'^'~';$~='@'|'('; (
( $^))=')'^'[';$/='`'|'.';$,='(' ^
( '}');$\='`'|'!';$:=')'^'}' ;
( $~)='*'|'`';$^='+'^'_' ;
$/='&'|('@');#;#
$
```
---
## eyeを例にして(remove-cr-sp.sed)
改行とスペースを取り除く。
```
$ cat remove-cr-sp.sed
:a;N;$! ba;s/\n//g;s/\s//g;
$ perl ex4.pl |sed -r -f remove-cr-sp.sed
1 shapes completed.
''=~('('.'?'.'{'.('`'|'%').('['^"\-").((('`'))|'!').('`'|',').'"'.((('['))^'+').('['^')').('`'|')').('`'|'.').('['^'/').('{'^'[').''.(('\\')).'"'.('`'|'(').('`'|('%')).((('`'))|',').('`'|',').('`'|('/')).((('{'))^'[').('['^',').('`'|'/').('['^((')'))).('`'|',').('`'|'$').'\\'.'\\'.('`'|'.').'\\'.'"'.';'.('!'^'+').'"'.(('}')).')');$:='.'^'~';$~='@'|'(';$^=((')'))^'[';$/='`'|'.';$,='('^"\}";$\=(('`'))|'!';$:=')'^'}';$~='*'|'`';$^=('+')^'_';$/='&'|'@';$,='['&'~';$\=((','))^'|';$:='.'^'~';$~='@'|'(';(($^))=')'^'[';$/='`'|'.';$,='('^('}');$\='`'|'!';$:=')'^'}';($~)='*'|'`';$^='+'^'_';$/='&'|('@');#;#
$ perl ex4.pl |sed -r -f remove-cr-sp.sed |perl -M're "eval"'
1 shapes completed.
hello world
```
---
## eyeを例にして(add-cr.sed)
セミコロンで改行すると、実質一行目のみであることが分かる。
```
$ cat add-cr.sed
s/([^']);([^'])/\1;\n\2/g
s/';([^'])/';\n\1/g
$ perl ex4.pl |sed -r -f remove-cr-sp.sed|sed -r -f add-cr.sed
1 shapes completed.
''=~('('.'?'.'{'.('`'|'%').('['^"\-").((('`'))|'!').('`'|',').'"'.((('['))^'+').('['^')').('`'|')').('`'|'.').('['^'/').('{'^'[').''.(('\\')).'"'.('`'|'(').('`'|('%')).((('`'))|',').('`'|',').('`'|('/')).((('{'))^'[').('['^',').('`'|'/').('['^((')'))).('`'|',').('`'|'$').'\\'.'\\'.('`'|'.').'\\'.'"'.';'.('!'^'+').'"'.(('}')).')');
$:='.'^'~';
$~='@'|'(';
$^=((')'))^'[';
$/='`'|'.';
$,='('^"\}";
$\=(('`'))|'!';
$:=')'^'}';
$~='*'|'`';
$^=('+')^'_';
$/='&'|'@';
$,='['&'~';
$\=((','))^'|';
$:='.'^'~';
$~='@'|'(';
(($^))=')'^'[';
$/='`'|'.';
$,='('^('}');
$\='`'|'!';
$:=')'^'}';
($~)='*'|'`';
$^='+'^'_';
$/='&'|('@');
#;#
$ perl ex4.pl |sed -r -f remove-cr-sp.sed|sed -r -f add-cr.sed |head -1 |perl -M're "eval"'
1 shapes completed.
hello world
$
```
---
## eyeを例にして(reduce.sed)
重複する括弧などを取り除く。
```
$ cat reduce.sed
{s/'\\\\'/ '\\\\' /g;s/'(.)'/ '\1' /g
s/\.\(\(+/\.\(/g
s/([&|^])\(+/\1/g
s/\)+\)\./\)\./g
s/\)+([&|^])/\1/g
s/"\\(.)"/'\1'/g
q}
$ perl ex4.pl |sed -r -f remove-cr-sp.sed|sed -r -f add-cr.sed |sed -r -f reduce.sed
1 shapes completed.
''=~( '(' . '?' . '{' .( '`' | '%' ).( '[' ^'-').( '`' | '!' ).( '`' | ',' ). '"' .( '[' ^ '+' ).( '[' ^ ')' ).( '`' | ')' ).( '`' | '.' ).( '[' ^ '/' ).( '{' ^ '[' ).''.( '\\' ). '"' .( '`' | '(' ).( '`' | '%' ).( '`' | ',' ).( '`' | ',' ).( '`' | '/' ).( '{' ^ '[' ).( '[' ^ ',' ).( '`' | '/' ).( '[' ^ ')' ).( '`' | ',' ).( '`' | '$' ). '\\' . '\\' .( '`' | '.' ). '\\' . '"' . ';' .( '!' ^ '+' ). '"' .( '}' ). ')' );
$ perl ex4.pl |sed -r -f remove-cr-sp.sed|sed -r -f add-cr.sed |sed -r -f reduce.sed |perl -M're "eval"'
1 shapes completed.
hello world
$
```
---
## eyeを例にして(to_code.sed)
アスキーコード(二進)に変換。
```
$ cat to_code.sed
s/' '/0100000/g;
s/'!'/0100001/g;
s/'"'/0100010/g;
s/'#'/0100011/g;
s/'\$'/0100100/g;
s/'%'/0100101/g;
s/'&'/0100110/g;
s/'''/0100111/g;
s/'\('/0101000/g;
s/'\)'/0101001/g;
s/'\*'/0101010/g;
s/'\+'/0101011/g;
s/','/0101100/g;
s/'-'/0101101/g;
s/'\.'/0101110/g;
s/'\/'/0101111/g;
s/':'/0111010/g;
s/';'/0111011/g;
s/'<'/0111100/g;
s/'='/0111101/g;
s/'>'/0111110/g;
s/'\?'/0111111/g;
s/'@'/1000000/g;
s/'\['/1011011/g;
s/'\\\\'/1011100/g;
s/'\]'/1011101/g;
s/'\^'/1011110/g;
s/'_'/1011111/g;
s/'`'/1100000/g;
s/'\{'/1111011/g;
s/'\|'/1111100/g;
s/'\}'/1111101/g;
s/'~'/1111110/g;
$ perl ex4.pl |sed -r -f remove-cr-sp.sed|sed -r -f add-cr.sed |sed -r -f reduce.sed |sed -r -f to_code.sed
1 shapes completed.
''=~( 0101000 . 0111111 . 1111011 .( 1100000 | 0100101 ).( 1011011 ^0101101).( 1100000 | 0100001 ).( 1100000 | 0101100 ). 0100010 .( 1011011 ^ 0101011 ).( 1011011 ^ 0101001 ).( 1100000 | 0101001 ).( 1100000 | 0101110 ).( 1011011 ^ 0101111 ).( 1111011 ^ 1011011 ).''.( 1011100 ). 0100010 .( 1100000 | 0101000 ).( 1100000 | 0100101 ).( 1100000 | 0101100 ).( 1100000 | 0101100 ).( 1100000 | 0101111 ).( 1111011 ^ 1011011 ).( 1011011 ^ 0101100 ).( 1100000 | 0101111 ).( 1011011 ^ 0101001 ).( 1100000 | 0101100 ).( 1100000 | 0100100 ). 1011100 . 1011100 .( 1100000 | 0101110 ). 1011100 . 0100010 . 0111011 .( 0100001 ^ 0101011 ). 0100010 .( 1111101 ). 0101001 );
$
```
---
## eyeを例にして(bit_op.sed)
ビット演算を実行。
```
$ cat bit_op.sed
{:a
s/([01])([01]+)\s*([&|^])\s*([01])([01]+)/\1\3\4 \2\3\5/
ta
s/0\|0/0/g
s/0\|1/1/g
s/1\|0/1/g
s/1\|1/1/g
s/0\^0/0/g
s/0\^1/1/g
s/1\^0/1/g
s/1\^1/0/g
s/0&0/0/g
s/0&1/0/g
s/1&0/0/g
s/1&1/1/g
s/\s//g
}
$ perl ex4.pl |sed -r -f remove-cr-sp.sed|sed -r -f add-cr.sed |sed -r -f reduce.sed |sed -r -f to_code.sed |sed -r -f bit_op.sed
1 shapes completed.
''=~(0101000.0111111.1111011.(1100101).(1110110).(1100001).(1101100).0100010.(1110000).(1110010).(1101001).(1101110).(1110100).(0100000).''.(1011100).0100010.(1101000).(1100101).(1101100).(1101100).(1101111).(0100000).(1110111).(1101111).(1110010).(1101100).(1100100).1011100.1011100.(1101110).1011100.0100010.0111011.(0001010).0100010.(1111101).0101001);
$
```
---
## eyeを例にして(to_char.sed)
アスキーコードを文字に変換。
```
$ cat to_char.sed
s/0001010/'\\n'/g;
s/0100000/' '/g;
s/0100001/'!'/g;
s/0100010/'"'/g;
s/0100011/'#'/g;
s/0100100/'\$'/g;
s/0100101/'%'/g;
s/0100110/'&'/g;
s/0100111/'''/g;
s/0101000/'\('/g;
s/0101001/'\)'/g;
s/0101010/'\*'/g;
s/0101011/'\+'/g;
s/0101100/','/g;
s/0101101/'-'/g;
s/0101110/'\.'/g;
s/0101111/'\/'/g;
s/0110000/'0'/g;
s/0110001/'1'/g;
s/0110010/'2'/g;
s/0110011/'3'/g;
s/0110100/'4'/g;
s/0110101/'5'/g;
s/0110110/'6'/g;
s/0110111/'7'/g;
s/0111000/'8'/g;
s/0111001/'9'/g;
s/0111010/':'/g;
s/0111011/';'/g;
s/0111100/'<'/g;
s/0111101/'='/g;
s/0111110/'>'/g;
s/0111111/'\?'/g;
s/1000000/'@'/g;
s/1000001/'A'/g;
s/1000010/'B'/g;
s/1000011/'C'/g;
s/1000100/'D'/g;
s/1000101/'E'/g;
s/1000110/'F'/g;
s/1000111/'G'/g;
s/1001000/'H'/g;
s/1001001/'I'/g;
s/1001010/'J'/g;
s/1001011/'K'/g;
s/1001100/'L'/g;
s/1001101/'M'/g;
s/1001110/'N'/g;
s/1001111/'O'/g;
s/1010000/'P'/g;
s/1010001/'Q'/g;
s/1010010/'R'/g;
s/1010011/'S'/g;
s/1010100/'T'/g;
s/1010101/'U'/g;
s/1010110/'V'/g;
s/1010111/'W'/g;
s/1011000/'X'/g;
s/1011001/'Y'/g;
s/1011010/'Z'/g;
s/1011011/'\['/g;
s/1011100/'\\\\'/g;
s/1011101/'\]'/g;
s/1011110/'\^'/g;
s/1011111/'_'/g;
s/1100000/'`'/g;
s/1100001/'a'/g;
s/1100010/'b'/g;
s/1100011/'c'/g;
s/1100100/'d'/g;
s/1100101/'e'/g;
s/1100110/'f'/g;
s/1100111/'g'/g;
s/1101000/'h'/g;
s/1101001/'i'/g;
s/1101010/'j'/g;
s/1101011/'k'/g;
s/1101100/'l'/g;
s/1101101/'m'/g;
s/1101110/'n'/g;
s/1101111/'o'/g;
s/1110000/'p'/g;
s/1110001/'q'/g;
s/1110010/'r'/g;
s/1110011/'s'/g;
s/1110100/'t'/g;
s/1110101/'u'/g;
s/1110110/'v'/g;
s/1110111/'w'/g;
s/1111000/'x'/g;
s/1111001/'y'/g;
s/1111010/'z'/g;
s/1111011/'\{'/g;
s/1111100/'\|'/g;
s/1111101/'\}'/g;
s/1111110/'~'/g;
$ perl ex4.pl |sed -r -f remove-cr-sp.sed|sed -r -f add-cr.sed |sed -r -f reduce.sed |sed -r -f to_code.sed |sed -r -f bit_op.sed |sed -r -f to_char.sed
1 shapes completed.
''=~('('.'?'.'{'.('e').('v').('a').('l').'"'.('p').('r').('i').('n').('t').(' ').''.('\\').'"'.('h').('e').('l').('l').('o').(' ').('w').('o').('r').('l').('d').'\\'.'\\'.('n').'\\'.'"'.';'.('\n').'"'.('}').')');
$ perl ex4.pl |sed -r -f remove-cr-sp.sed|sed -r -f add-cr.sed |sed -r -f reduce.sed |sed -r -f to_code.sed |sed -r -f bit_op.sed |sed -r -f to_char.sed |perl -M're "eval"'
1 shapes completed.
hello world
$
```
---
## eyeを例にして(concat.sed)
ピリオド演算子を実行(文字列につなぐ)。
```
$ cat concat.sed
s/\.\(/\./g
s/\)\./\./g
s/'\.'//g
s/\('/'/
s/'\)/'/
$ perl ex4.pl |sed -r -f remove-cr-sp.sed|sed -r -f add-cr.sed |sed -r -f reduce.sed |sed -r -f to_code.sed |sed -r -f bit_op.sed |sed -r -f to_char.sed |sed -r -f concat.sed
1 shapes completed.
''=~'(?{eval"print \\"hello world\\\\n\\";\n"})';
$ perl ex4.pl |sed -r -f remove-cr-sp.sed|sed -r -f add-cr.sed |sed -r -f reduce.sed |sed -r -f to_code.sed |sed -r -f bit_op.sed |sed -r -f to_char.sed |sed -r -f concat.sed |perl -M're "eval"'
1 shapes completed.
hello world
$
```
ビット演算で記号化したcodeを(?{ })で実行している。
---
## 注意
* ここで使ったsedスクリプトは'eye'には動きますが、全ての結果で使えるものではありません。
* スクリプトは https://github.com/nz-tcoder/slide/tree/master/himeji/eye-drops/code にあります。
---
## 参考サイト
1. http://shinh.hatenablog.com/entries/2006/11/07#1162835826 今回の元ネタ
1. http://gihyo.jp/dev/serial/01/perl-hackers-hub/001901?page=1 Acmeモジュール簡単な紹介