my $constant; for $constant (keys %constants) { $line =~ s/$constant/$constants{$constant}/g; }