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 6001587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:51:21+00:00 2026-05-23T00:51:21+00:00

Okay, not sure where to ask this, but I’m a beginner programmer, using Perl.

  • 0

Okay, not sure where to ask this, but I’m a beginner programmer, using Perl. I need to create an array of an array, but I’m not sure if it would be better use array/hash references, or array of hashes or hash of arrays etc.

I need an array of matches: @totalmatches

Each match contains 6 elements(strings):

@matches = ($chapternumber, $sentencenumber, $sentence, $grammar_relation, $argument1, $argument2)

I need to push each of these elements into the @matches array/hash/reference, and then push that array/hash/reference into the @totalmatches array.

The matches are found based on searching a file and selecting the strings based on meeting the criteria.

QUESTIONS

  1. Which data structure would you use?

  2. Can you push an array into another array, as you would push an element into an array? Is this an efficient method?

  3. Can you push all 6 elements simultaneously, or have to do 6 separate pushes?

  4. When working with 2-D, to loop through would you use:

    foreach (@totalmatches) {
    foreach (@matches) {
    …
    }
    }

Thanks for any advice.

  • 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-23T00:51:22+00:00Added an answer on May 23, 2026 at 12:51 am

    Do not push one array into another array.
    Lists just join with each other into a new list.

    Use list of references.

    #create an anonymous hash ref for each match
    $one_match_ref = {
         chapternumber => $chapternumber_value, 
         sentencenumber => $sentencenumber_value, 
         sentence => $sentence_value,
         grammar_relation => $grammar_relation_value, 
         arg1 => $argument1, 
         arg2 => $argument2
    };
    
    # add the reference of match into array.
    push @all_matches, $one_match_ref;
    
    # list of keys of interest
    @keys = qw(chapternumber sentencenumber sentence grammer_relation arg1 arg2);
    # walk through all the matches.
    foreach $ref (@all_matches) {
        foreach $key (@keys) {
            $val = $$ref{$key};
    
        }
        # or pick up some specific keys
        my $arg1 = $$ref{arg1};
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Not sure if this is an okay place to ask, but i'll try). After
Okay, so not sure if apple.stackexchange is a better place for this, but I
Okay, so I'm not even sure how to ask this question (much less search
I'm not sure what's going on, but on my own laptop, everything works okay.
Okay, I feel totally stupid posting this. I am not sure if it is
Okay I'm looking for some input, I'm pretty sure this is not currently supported
Okay so I'm not using any session variables, rather my code looks like this:
Okay i know i have to use the JDBC etc, but im not sure
Okay i have this problem with every page i make. im not sure what
Okay, now I've got this thing I need to do with Javascript but I

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.