Created
August 7, 2013 16:03
-
-
Save manchicken/6175459 to your computer and use it in GitHub Desktop.
Was asked this question, it seems like something we should know how to do.
This file contains 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
#!/usr/bin/env perl | |
use strict; use warnings; | |
if (scalar(@ARGV) != 1) { | |
die "Usage: $0 INTEGER"; | |
} | |
my $in = $ARGV[0]; | |
if ($in !~ m/^-?[0-9]+$/) { | |
die "Usage: $0 INTEGER (and it really must be an integer)"; | |
} | |
my $remainder = (abs($in) % 10); | |
if ($remainder == 4) { | |
print "$in ends in 4!\n"; | |
} else { | |
print "$in doesn't end in 4!\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment