Skip to content

Instantly share code, notes, and snippets.

@manchicken
Created August 7, 2013 16:03
Show Gist options
  • Save manchicken/6175459 to your computer and use it in GitHub Desktop.
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.
#!/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