Skip to content

Instantly share code, notes, and snippets.

@kureikei
Created Mar 3, 2015
Embed
What would you like to do?
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