diff --git a/1-binary_gap.pl b/1-binary_gap.pl index 3b51bac..35bd357 100755 --- a/1-binary_gap.pl +++ b/1-binary_gap.pl @@ -8,12 +8,30 @@ use lib "$FindBin::RealBin/lib"; use lib 'lib'; use BinaryGap; -use Data::Dumper; - -print "Input: " . Dumper($ARGV[0]); - my $number = $ARGV[0]; -my $answer = BinaryGap::solution($number); -print "Got answer $answer\n"; +if (scalar(@ARGV) != 1) { + die "Usage: $0 \n"; +} -exit; \ No newline at end of file +my $answer = BinaryGap::solution($number); +print "The binary gap of $number is $answer\n"; + +exit; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +binary_gap.pl - Find longest sequence of zeros in binary representation of an integer. Script used to call BinaryGap. + +=head1 SYNOPSIS + +binary_gap.pl + +=head1 DESCRIPTION + +This script is used to exercise BinaryGap.pm. It takes one integer as input. It returns the binary gap (longest sequence of zeros) in the binary representation of the input number. diff --git a/lib/BinaryGap.pm b/lib/BinaryGap.pm index 2dcb118..c40ed18 100644 --- a/lib/BinaryGap.pm +++ b/lib/BinaryGap.pm @@ -61,4 +61,14 @@ sub solution { return $max_gap; } -1; \ No newline at end of file +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +BinaryGap - Find longest sequence of zeros in binary representation of an integer. If there is none, this returns 0.