From d41e61a05e27497cccf765c8e23a6eabdcef4afc Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 23 Dec 2010 23:51:48 +0100 Subject: hash_in_db: Use keys, not each. Shot myself in the foot without noticing. --- bin/hashl | 12 +++++++----- 1 file 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 = ) { 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; } } -- cgit v1.2.3