Created
December 10, 2013 10:07
-
-
Save rsslldnphy/7888386 to your computer and use it in GitHub Desktop.
Bob in Perl5
This file contains hidden or 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; | |
{ | |
package Bob; | |
sub hey { | |
if (&_shouting) { | |
"Woah, chill out!" | |
} elsif (&_question) { | |
"Sure." | |
} elsif (&_silence) { | |
"Fine. Be that way!" | |
} else { | |
"Whatever." | |
} | |
} | |
sub _silence { | |
my ($input) = @_; | |
$input =~ /^\s*$/; | |
} | |
sub _question { | |
my ($input) = @_; | |
$input =~ /\?$/; | |
} | |
sub _shouting { | |
my ($input) = @_; | |
($input eq uc $input) && (lc $input ne $input); | |
} | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment