... if (defined $changes{$file}) { # skip if this $line isn't mentioned in $changes next unless ($changes{$file} =~ / $line /); } ...