Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8700531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:11:18+00:00 2026-06-13T02:11:18+00:00

I have a perl data structure similar to the following: $VAR1 = bless( {

  • 0

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’ ..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:11:19+00:00Added an answer on June 13, 2026 at 2:11 am

    blessing reference only add arbitrary type description to it and doesn’t change working with it in any other way, unless you use overload, so exactly same loop as with unblessed references will work:

    foreach my $group (@{$VAR1->{groups_list}}) {
       if ($group->{groupid} eq 'webuser') {
          # do stuff and break out
       }
    }
    

    You can also replace loop with grep if you only need inner hashes with data without their indices in array:

    my @webusers = grep { $_->{groupid} eq 'webuser' } @{$VAR1->{groups_list}};
    

    This will search entire list though. Use first from List::Util to only find first match.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Perl data structure like the following: %hash = ( table_id =>
In Perl, when you have a nested data structure, it is permissible to omit
I have a program which accepts a perl data structure which is intended to
In a quick-and-dirty Perl script, I have a data structure like this: $tax_revenue{YEAR}{STATE}{GOVLEV}{TAX} =
I have a rather complex data structure I've implemented in Perl. This has been
I have a collection in mongo in which I am inserting data from Perl
I have some data generated in MATLAB that I want to process using Perl.
I have this script: #!/var/home/cherry/opt/perl use Test::More; use DBI; use Test::mysqld; use Data::Dumper; my
I have a data structure in redis that uses sorted sets for a top
I am experiencing weird behavior with template toolkit, say I have a data structure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.