第3回2ch全板人気トーナメント@UNIX板

このエントリーをはてなブックマークに追加
613戦時板国民
#!/usr/bin/perl
use strict;
my @dayomon = reverse qw/だよ もん/;
my @mode = qw/dayomon decimal/;
my $term = 'だよもん!';

die "Usage: perl dayomon.pl dayomon|decimal\n" if $ARGV[0] !~ /^\d+$|^($dayomon[0]|$dayomon[1])+${term}$/;

my $result = $ARGV[0];
my $flag = $result !~ /^\d+$/;

if ($flag) {
$result =~ s/$term//;
$result =~ s/$dayomon[$_]/$_/g for (0..1);
$result = oct("0b$result");
} else {
$result = sprintf("%b", $result);
$result =~ s/$_/$dayomon[$_]/g for (0..1);
$result .= $term;
}
printf("%s: %s\n", $mode[$flag], $result);
__END__

ダヨモン様、御久シ振リトナリマシタンダヨモン。
ダヨモンダヨダヨダヨモン!日ノ組決勝デハ一緒ニ遊ンデ下サリ、感謝シテヰマスダヨモン。

燃エ尽キテ仕舞ヒ、守護神殿ノ御礼モ持チ帰リモ今頃ニナツタノガ心苦シインダヨモン。
反省シテ更ナル現実逃避ニ走ツタダヨモンガ、コンナ伊国麺デハ困ルンダヨモン…。