When you are entering the measureFieldLength subroutine, you are copying the argument $allActivity_fieldLength_hashref (which is undef at this point) into the $tableName_fieldLength_hashref variable. You are then populating the hash referred to by $tableName_fieldLength_hashref, but the global $allActivity_fieldLength_hashref variable remains undef throughout the process.

You might want to return $tableName_fieldLength_hashref to the caller function when exiting the measureFieldLength and modify this function to assign that return value to the $allActivity_fieldLength_hashref global variable. Or, alternatively, work directly on the global variable within the subroutine (although this is far from being clean).

In brief, you should either decide your variables are global and, in this case, you should not pass them around as arguments (this is not the best solution, but at least it would probably work the way you want), or you don't make them global and pass them around as arguments and return values (which would be considered a better solution). But don't mix the alternatives, that's what is getting you into trouble.

Update: I would add that your program is difficult to read and to understand because your variable and function names are too long and too similar, and using CamelCase doesn't make your identifiers easy to read.

Also, why are you using subroutine prototypes? Are you sure you understand and need them?


In reply to Re: no visibility to global hashref ?!? by Laurent_R
in thread no visibility to global hashref ?!? by kerchunk

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.