in reply to Re: Hash Values into Array
in thread Hash Values into Array
"for $my os (values %info) {"
Two corrections:
"This should also work if you have several errors possible for one testcase, such as 'error1', 'error2', etc."
You're manufacturing data that the OP hasn't specified or even hinted at. I don't think this is a good idea. Furthermore, you're not targeting the specific key (i.e. error) that the OP did specify; you are, in fact, targeting every key that exists. Consider this scenario (using your code, with the corrections shown above):
$ perl -Mstrict -Mwarnings -le ' my $info = { win => { t1 => { error => "missing arg" }, t2 => { skipped => "no network" } }, nix => { t1 => { error => "wrong type" }, t2 => { success => 1 } } }; my @errors; for my $os (values %$info) { for my $testcase (values %$os) { push @errors, values %$testcase } } print for @errors; ' no network missing arg wrong type 1
-- Ken
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Hash Values into Array
by Laurent_R (Canon) on Aug 17, 2013 at 08:08 UTC |