Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env perl
use strict;
use warnings;
while( chomp(my $input = <STDIN>) ) {
# 入力された文字を判定
last if $input eq '0';
# 文字列の内容によって書き換える
print 'Find Perl!'."\n" if $input =~ m/[Pp]erl/;
print 'Find Python!'."\n" if $input =~ m/python/i;
print 'Love Programming!'."\n" if $input =~ m/(?:perl|ruby|python)/;
print 'Find papix!'."\n" if $input =~ m/\Apapix/;
print 'Hello! '.$1.'!'."\n" if $input =~ m/Hello\s*(.+)\z/;
if( $input =~ m/\A(.+)。/ ) {
print $1.nyaan()."\n";
} else {
print '「にゃーん?」'."\n"
sub nyaan {
# ニャーとかニャーーーーを返す
my $nyaa = 'ニャ';
my $dash = '' x int(rand(9));
return $nyaa.$dash;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment