NOW IT WORKS, I must have fat-fingered the previous 300 times. Please disregard.
Esteemed (and steamy) monks, I'm trying to dereference a hash to build a link. I've run a query and am looping thru an array of arrays to build a table. On the third column I want to insert the link - using the contents of that column @$_[1] to derefernce the value from the hash $real_hash->{@$_[0]}, but I get no data. I'm wondering if behind the scenes I'm overwriting some built-in variable. Thanks in advance for your help. Code follows ---------------
sub makeTable { my ($ref, $cols) = @_; my $one_col = ""; #pull in ref. to hash (doc. name, URL) my $links_ref = ($cols =~ /MPS/) ? &getMPSlinks : ""; #----make column titles, and begin html code for table my @cols = split (/,/,$cols); foreach (@cols) {$labels .= qq|<td>$_</td>|;} my $table = qq|<table class="center"><tr class="table_labels">$lab +els</tr>|; foreach (@$ref) { #loop thru array of arrays, inside we'll take ea +ch array and break out into table $table .= ++$count % 2 == 1 ? qq|<tr class="row_light">| : qq|< +tr class="row_dark">|; #alaternate row colors #---Build tables here------------------------------------------ +----- if ($form{"query"} eq "deptcodes") { my $doc_num = qq|@$_[2]|; #PROBLEM CHILD ON NEXT LINE $table .= qq|<td>@$_[0]</td><td>@$_[1]</td><td><a href="$ +links_ref->{@$_[0]}" target="_blank">@$_[2]</a></td>|; + } } $table .= "</table>"; return($table); } #this returns a ref to a hash. key is doc. name, value is URL sub getMPSlinks { our %mps_hash=(); my ($one_mps, $one_url) = ""; open(HANDLE, "< $cgi_path/mpslinks.txt") or die "***Couldn't +open $path for reading: $!\n"; while (<HANDLE>) { ($one_mps, $one_url) = split (/\|/,$_); $mps_hash{$one_mps} = "$one_url"; #print "<strong>$one_mps</strong><br> $one_url"; } close (HANDLE); return (\%mps_hash); }

In reply to trouble dereferencing a hash reference by hipnoodle

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.