diff --git a/perl/Amanda/Recovery/Planner.pm b/perl/Amanda/Recovery/Planner.pm
index 87f0032..b0952a9 100644
--- a/perl/Amanda/Recovery/Planner.pm
+++ b/perl/Amanda/Recovery/Planner.pm
@@ -409,13 +409,13 @@ sub make_plan_from_filelist {
 	    labels => [ @labels ]);
 
     # filter down to the parts that match filelist (using %files)
-    my $in_filelist = sub {
+    @parts = grep {
 	my $filenum = $_->{'filenum'};
 	grep { $_ == $filenum } @{$files{$_->{'label'}}};
-    };
-    @parts = grep $in_filelist, @parts;
+    } @parts;
 
-    # extract the dumps, using a hash to ensure uniqueness
+    # extract the dumps, using a hash (on the perl identity of the dump) to
+    # ensure uniqueness
     my %dumps = map { my $d = $_->{'dump'}; ($d, $d) } @parts;
     my @dumps = values %dumps;
 
