Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
I modified the script to use Data::Dumper after the assignment to @content{@selector} and after the loop. Using the test data
test1 test2 test3 test4 test44 afsd wfsdf sdfsd
I got the output
$VAR1 = 'field1'; $VAR2 = 'test1'; $VAR3 = 'field2'; $VAR4 = 'test2'; $VAR5 = 'field3'; $VAR6 = 'test3'; $VAR7 = 'field4'; $VAR8 = 'test4';
after the first assignment, so the hash is indeed being set up correctly. After the loop, my RefHash was set to
$VAR1 = { 'field1' => 'test1', 'field2' => 'test2', 'field3' => 'test3', 'field4' => 'test4' }; $VAR2 = { 'field1' => 'test44', 'field2' => 'afsd', 'field3' => 'wfsdf', 'field4' => 'sdfsd' };
so it appears that the push worked. Perhaps your problem is to do with the way that you are trying to access the array elements? I was able to access it with
print $RefHash[0]{'field2'},"\n";

In reply to Re: Assignment of Arrays of Hashes by physgreg
in thread Assignment of Arrays of Hashes by Tanalis

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.