Ah, the joys of debugging global variables! Iron-clad employment insurance!! You'll be working on this until the end of time — or until the company goes under, not unlikely if they've got a lot of code like this.

Here's one approach, not necessarily the best: track down the package the hash lives in (assuming it's a package global):

c:\@Work\Perl\monks>perl -wMstrict -le "no strict qw(refs vars); no warnings; ;; package Foo; %CONTACTS = ('hello' => 'sailor'); ;; package Bar; $ZOT{'autovivified'} = 'bam'; ;; package main; ;; my $rx_pkg = qr{ \A (?: [[:alpha:]] [[:alnum:]]* ::)+ \z }xms; ;; print qq{'$_'} for grep m{ $rx_pkg }xms, keys %main:: ; print ''; ;; print qq{'$_' has 'CONTACTS'} for grep exists ${$_}{CONTACTS}, grep m{ $rx_pkg }xms, keys %main:: ; print ''; ;; print qq{'$_' has 'ZOT'} for grep exists ${$_}{ZOT}, grep m{ $rx_pkg }xms, keys %main:: ; print ''; ;; print $Foo::CONTACTS{'hello'}; print $Bar::ZOT{'autovivified'}; " 'version::' 'utf8::' 're::' 'CORE::' 'DynaLoader::' 'mro::' 'strict::' 'Win32CORE::' 'Bar::' 'Regexp::' 'UNIVERSAL::' 'Foo::' 'main::' 'Carp::' 'Win32::' 'PerlIO::' 'IO::' 'Exporter::' 'Internals::' 'warnings::' 'DB::' 'Foo::' has 'CONTACTS' 'Bar::' has 'ZOT' sailor bam
Note that:

Updates:

  1. Added
        no strict qw(refs vars);
        no warnings;
    statements to example code.
  2. Check out Packages and Symbol Tables in perlmod.
  3. Actually, on re-reading the docs, I think
        my $rx_pkg = qr{ \A (?: [[:alpha:]_] \w* ::)+ \z }xms;
    would be a better definition of the package name regex.


Give a man a fish:  <%-(-(-(-<


In reply to Re: Finding Location of Hash Structure? by AnomalousMonk
in thread Finding Location of Hash Structure? by mdskrzypczyk

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.