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";
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.