I have a perl data structure similar to the following:
$VAR1 = bless( {
'admin' => '0',
'groups_list' => [
bless( {
'name' => undef,
'groupid' => 'canedit',
'description' => 'Can Edit Articles'
}, 'group_entry' ),
bless( {
'name' => undef,
'groupid' => 'webuser',
'description' => 'Can Access Content'
}, 'group_entry' ),
],
'trusted' => '1',
}, 'user_info' );
I am looking for a way to loop thru all the groups in 'groups_list' and check if we have 'webuser' groupid in it. Any help is appreciated.
Also, kindly let me know if this can be done without using a loop.. something like searching for the string 'groupid' => 'webuser' ..
blessing reference only add arbitrary type description to it and doesn't change working with it in any other way, unless you useoverload, so exactly same loop as with unblessed references will work:You can also replace loop with
grepif you only need inner hashes with data without their indices in array:This will search entire list though. Use
firstfromList::Utilto only find first match.