Skip to content

Instantly share code, notes, and snippets.

@rsslldnphy
Created December 10, 2013 10:07
Show Gist options
  • Save rsslldnphy/7888386 to your computer and use it in GitHub Desktop.
Save rsslldnphy/7888386 to your computer and use it in GitHub Desktop.
Bob in Perl5
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