in reply to Adding values to registry

The previous reply contained good advice. I would add the following observation, about the variable "$key" in your code:

It is initially assigned as a scalar variable:

... if( $count eq 1 ) { ... $key = $keyGlobal; } else { ... $key = $keyFed; } ...

Then, later on, the same variable name ("key") is used as a hash:

if( $fileline =~ "..." && $found eq 0 ) { $key{'/Repo Version'} = "$1"; $found = 1; }

If the initial assignment to "$key" was intended to be a reference to a hash, then assigning a value to an element of the hash requires the use of a de-reference operator, like this:

$key->{'/Repo Version'} = $1;
Since your original code did not use de-reference, your assignment of "$1" to "$key{'/Repo Version'} caused a new hash array to be declared at that point -- note that when the same name is used for a scalar and a hash (and/or an array), Perl treats the scalar and the hash (and/or the array) as different storage locations, whose values are completely distinct and unrelated.