line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Tategaki; |
2
|
3
|
|
|
3
|
|
100385
|
use 5.008005; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
107
|
|
3
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
116
|
|
4
|
3
|
|
|
3
|
|
26
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
83
|
|
5
|
3
|
|
|
3
|
|
987
|
use utf8; |
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
16
|
|
6
|
3
|
|
|
3
|
|
7273
|
use Array::Transpose::Ragged qw/transpose_ragged/; |
|
3
|
|
|
|
|
5874
|
|
|
3
|
|
|
|
|
189
|
|
7
|
3
|
|
|
3
|
|
26329
|
use Encode qw/encode_utf8 decode_utf8/; |
|
3
|
|
|
|
|
50239
|
|
|
3
|
|
|
|
|
543
|
|
8
|
3
|
|
|
3
|
|
4375
|
use Data::Dump qw/dump/; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use parent 'Exporter'; |
11
|
|
|
|
|
|
|
our @EXPORT = qw( tategaki tategaki_one_line); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = "0.12"; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my @punc = qw(、 。 , .); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub tategaki_one_line { |
18
|
|
|
|
|
|
|
my $text = shift; |
19
|
|
|
|
|
|
|
return _convert_vertical(($text)); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub tategaki { |
24
|
|
|
|
|
|
|
my $text = shift; |
25
|
|
|
|
|
|
|
$text =~ s/$_\s?/$_ /g for @punc; |
26
|
|
|
|
|
|
|
my @text = split /\s/, $text; |
27
|
|
|
|
|
|
|
return _convert_vertical(@text); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _convert_vertical { |
31
|
|
|
|
|
|
|
my @text = @_; |
32
|
|
|
|
|
|
|
@text = map { [ split //, $_ ] } @text; |
33
|
|
|
|
|
|
|
@text = transpose_ragged( \@text ); |
34
|
|
|
|
|
|
|
@text = map { [ map {$_ || ' ' } @$_ ] } @text; |
35
|
|
|
|
|
|
|
@text = map { join ' ', reverse @$_ } @text; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
for (@text) { |
38
|
|
|
|
|
|
|
$_ =~ tr//‥−-─ー「」→↑←↓==,、。〖〗【】…/\:||||¬∟↓→↑←॥॥︐︑︒︗︘︗︘︙/; |
39
|
|
|
|
|
|
|
$_ =~ s/〜/∫ /g; |
40
|
|
|
|
|
|
|
$_ =~ s/『/ ┓/g; |
41
|
|
|
|
|
|
|
$_ =~ s/』/┗ /g; |
42
|
|
|
|
|
|
|
$_ =~ s/[/┌┐/g; |
43
|
|
|
|
|
|
|
$_ =~ s/]/└┘/g; |
44
|
|
|
|
|
|
|
$_ =~ s/\[/┌┐/g; |
45
|
|
|
|
|
|
|
$_ =~ s/\]/└┘/g; |
46
|
|
|
|
|
|
|
$_ =~ s/</∧ /g; |
47
|
|
|
|
|
|
|
$_ =~ s/>/∨ /g; |
48
|
|
|
|
|
|
|
$_ =~ s/∧ /g; |
49
|
|
|
|
|
|
|
$_ =~ s/>/∨ /g; |
50
|
|
|
|
|
|
|
$_ =~ s/《/∧ /g; |
51
|
|
|
|
|
|
|
$_ =~ s/》/∨ /g; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
# print dump @text; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return join "\n", @text; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
if ( __FILE__ eq $0 ) { |
59
|
|
|
|
|
|
|
print encode_utf8(tategaki decode_utf8 'お前は、すでに、死んでいる。'), "\n"; |
60
|
|
|
|
|
|
|
print encode_utf8(tategaki_one_line decode_utf8 'お前は、すでに、死んでいる。'); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |