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

  • Home
  • SEARCH
  • 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 3879340
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:42:55+00:00 2026-05-19T22:42:55+00:00

I am new to complex data structures. I kind of understand the idea behind

  • 0

I am new to complex data structures. I kind of understand the idea behind them but am having some difficulty getting the data out. I found out the structure of my current problem child by using Data::Dumper….

$VAR1 = {
      '4' => {
               'engine_coded' => 0,
               'name' => 'FILTER_1',
               'filter_actions' => {
                                     'X_Override_Queue_Level' => 'Value'
                                   },
               'filter_criteria' => [
                                      [
                                        'X_Charge',
                                        '=',
                                        'X_CHARGE_1'
                                      ]
                                    ]
             }
    };

What I am needing to do is make sure that given a filter name (“4″ in this case”) that “name” has a value, as well as “filter_actions” and “filter_criteria”.

Anyone have an idea how to best accomplish this? Many thanks!
Janie

  • 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-05-19T22:42:55+00:00Added an answer on May 19, 2026 at 10:42 pm

    Let’s break this down into pieces…

    First, create a function which validates a structure:

    sub validate
    {
        my ($data) = @_;
    
        # always return true for now
        return 1;
    }
    

    Now let’s start filling in the bits… you want to use a filter name as part of the validation checks, so let’s add that as an argument:

    sub validate
    {
        my ($data, $filter_name) = @_;
    
        # always return true for now
        return 1;
    }
    

    Before doing anything else, it would make sense to check if that filter name exists as a key; if it doesn’t, validation has failed:

    sub validate
    {
        my ($data, $filter_name) = @_;
    
        return if not exists $data->{$filter_name};
    
        # otherwise, return true
        return 1;
    }
    

    Now also check that there is a value. Since definedness in a hash key is a superset of ‘exists’ (any value that is defined must also exist, but not every value that exists needs to be defined – as undef could be the value), the first check can be omitted:

    sub validate
    {
        my ($data, $filter_name) = @_;
    
        return if not defined $data->{$filter_name};
    
        # otherwise, return true
        return 1;
    }
    

    We’ve checked that the filter_name key is present in the data and it is defined, but before looking one level deeper, we need to confirm that it really is a hashref:

    sub validate
    {
        my ($data, $filter_name) = @_;
    
        return if not defined $data->{$filter_name};
    
        return if ref $data->{$filter_name} ne 'HASH';
    
        # otherwise, return true
        return 1;
    }
    

    Now look for the ‘filter_actions’ and ‘filter_criteria’ keys under the filter name:

    sub validate
    {
        my ($data, $filter_name) = @_;
    
        return if not defined $data->{$filter_name};
    
        return if ref $data->{$filter_name} ne 'HASH';
    
        return if not defined $data->{$filter_name}{filter_actions};
        return if not defined $data->{$filter_name}{filter_actions};
    
        # otherwise, return true
        return 1;
    }
    

    That’s it! Be sure to read up on using perl data structures in perldoc perlreftoot, perldoc perlref, and perldoc perldsc.

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

Sidebar

Related Questions

I have several complex data structures like Map< A, Set< B > > Set<
Suppose you want to start a new activity and pass it some data from
I am completely new to Flex. Can I realistically develop, say, a medium complex
New to javascript/jquery and having a hard time with using this or $(this) to
New to both Ruby and Rails but I'm book educated by now (which apparently
New to WCF, but familiar with COM+ - can I wrap a WCF service
The new extensions in .Net 3.5 allow functionality to be split out from interfaces.
I have a multithreaded C++ application which holds a complex data structure in memory
New class is a subclass of the original object It needs to be php4
New to xml. Looking for XPath to search a xml file with python ElementTree

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.