summaryrefslogtreecommitdiff
path: root/bin/hashl
diff options
context:
space:
mode:
Diffstat (limited to 'bin/hashl')
-rwxr-xr-xbin/hashl12
1 files changed, 7 insertions, 5 deletions
diff --git a/bin/hashl b/bin/hashl
index 52bc5a1..4a7ea92 100755
--- a/bin/hashl
+++ b/bin/hashl
@@ -90,7 +90,9 @@ sub hash_file {
sub hash_in_db {
my ($hash) = @_;
- while (my ($name, $file) = each(%{$db->{'files'}})) {
+ for my $name (keys %{$db->{'files'}}) {
+ my $file = $db->{'files'}->{$name};
+
if ($file->{'hash'} eq $hash) {
return $name;
}
@@ -117,10 +119,10 @@ sub db_find {
while (my $line = <STDIN>) {
chomp $line;
if (
- ($action eq 'know-file' and file_in_db($line)) or
- ($action eq 'know-hash' and hash_in_db($line)) or
- ($action eq 'new-file' and not file_in_db($line)) or
- ($action eq 'new-hash' and not hash_in_db($line))) {
+ ($action eq 'know-file' and defined file_in_db($line)) or
+ ($action eq 'know-hash' and defined hash_in_db($line)) or
+ ($action eq 'new-file' and not defined file_in_db($line)) or
+ ($action eq 'new-hash' and not defined hash_in_db($line))) {
say $line;
}
}