$source .= <<"EOF";
my \%attrs = (@attrs);
-my \@bad = sort grep { ! \$attrs{\$_} } keys \%params;
+my \@bad = sort grep { ! \$attrs{\$_} } keys \%{ \$params };
if (\@bad) {
Carp::confess "Found unknown attribute(s) passed to the constructor: \@bad";