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.

In reply to Re: Adding values to registry by graff
in thread Adding values to registry by spacejunky

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.