why wouldn't the name=>"Accounts" be picked upIn your original data the first element of the array is unwanted so toolic has @{ $data }[1 .. $#$data] which has the effect of skipping that first element. Arrays are indexed from "0" so the first element is $array[0], the second element is $array[1] and so on. So, @{ $data }[1 .. $#$data] means the range of elements starting at the second element and up to the last element.
A better way might be to use grep in combination with map:
Here grep first filters all the elements, discarding any which don't have a 'name' key, and then map constructs the desired data structure from the remaining elements.my @all_names = map { {name => $_->{name}} } grep { exists $_->{name} } @$data;
In reply to Re^5: Extracting elements from array
by tangent
in thread Extracting elements from array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |