The purpose of the following code is to put (a|multiple) hash(es) into an array, and then retrieve one particular hash value from the array. This simplifies things with HTML::Template's TMPL_LOOP mechanism, especially when retrieving data from MySQL.

The following code produces this:

Global symbol "@returnArray" requires explicit package name at ./test. +pl line 16. Execution of ./test.pl aborted due to compilation errors.
So, I'm obviously missing the boat somewhere. I've checked out several threads on the subject and reviewed what I believe are the applicable perldocs, but I'm just not getting it. (Would anyone tell me if I was getting stupider?) I think I've stared at and studied it for so long, I've gone blind to the simplicity of the situation.

Thanks for any insight or thoughts you guys might have. I really think I'm overlooking something fairly simple, but its eluding me.

#!/usr/bin/perl -w use strict; use Data::Dumper; my %hash = { 'node_id' => '1', 'node_title' => 'whiskey', 'node_author' => 'otis', 'node_content' => 'the path to wisdom is littered with empty bottle +s', }; my $returnArray; push @{$returnArray}, \%hash; print Dumper(${$returnArray}[0]{node_content});

If things get any worse, I'll have to ask you to stop helping me.


In reply to Modifying an Element in an Array of Hashes by shockme

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.