I have a Hash within an if-declaration (which is also in an foreach Loop). Outside of this loop, there is only the last entry of the hash left.
Why? And how can I receive the other 25 entries of the hash outside the declartion?
I really don't know, why this is happening.
$nodeset finds the right node in the document, which is the inputfile I want to check
foreach my $node ($nodeset->get_nodelist)
{
#this line below is just for checking, what can be found within
+the nodelist
my $a = $node->getAttribute('a');
my $b = $node->getAttribute('b');
my $c= $node->getAttribute('c');
if((defined $a) && (defined $b) && (defined $c))
{
@arr_a = split (/ /, $a);
@arr_b = split (/ /, $b);
@arr_c = split (/ /, $c);
}else{
print "Warning! \n";
}
%complete =(
@arr_a=>[@arr_b, @arr_c],
);
}
print Dumper %complete;
--> but here is the Problem. Outside of the Loop, there is only the last hash-element left.
I hope someone can help me and explain me whats the error.
regards
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.