aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheckem26
1 files changed, 11 insertions, 15 deletions
diff --git a/checkem b/checkem
index cc03781..aeb932d 100755
--- a/checkem
+++ b/checkem
@@ -40,23 +40,19 @@ my %STATS = (
size => 7,
);
-# We need to pick and create a Digest object
-my $dig;
-
-# We were told which algorithm to use
-if ( exists $ENV{CHECKEM_ALG} ) {
- $dig = Digest->new( $ENV{CHECKEM_ALG} );
-}
+# Use either the specified algorithm or a default list
+my @algs =
+ exists $ENV{CHECKEM_ALG}
+ ? $ENV{CHECKEM_ALG}
+ : qw(SHA-256 SHA-1 MD5);
-# Try worse and worse algorithms until we get a digest object
-else {
- for my $alg (qw(SHA-256 SHA-1 MD5)) {
- last if eval { $dig = Digest->new($alg) };
- }
+# Build digest object or give up
+my $dig;
+for (@algs) {
+ last if eval { $dig = Digest->new($_) };
}
-
-# Still no digest object, give up
-defined $dig or die "Could not create a useable Digest object\n";
+defined $dig
+ or die "Could not create a useable Digest object\n";
# Start a hash of filesizes to file names/stats...
my %sizes;