Skip to content

Instantly share code, notes, and snippets.

@kureikei
Created March 3, 2015 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kureikei/eb0c2e1c50caa7f9d7d5 to your computer and use it in GitHub Desktop.
Save kureikei/eb0c2e1c50caa7f9d7d5 to your computer and use it in GitHub Desktop.
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