-
-
Save kureikei/eb0c2e1c50caa7f9d7d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use utf8; | |
binmode(STDOUT, ":utf8"); | |
my($i,$j,$word); | |
my(@s) = reverse(split(/,/,"古池や,蛙飛びこむ,水の音")); | |
print process(0,@s); | |
sub process { | |
my($index) = shift; my($w,$v) = ""; my($k) = 0; my($result) = ""; my(@vert); | |
foreach $w (@_) { if ($k < length($w)) { $k = length($w); } } if ($index > $k) { return ""; } | |
foreach $w (@_) { | |
$k=0; $v=""; @vert = (split(//,$w)); | |
if (scalar(@vert) > $index) { $result .= $vert[$index]; } else { $result .= " "; } | |
} | |
return $result . "\n" . &process($index+1,@_) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment