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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:14:09+00:00 2026-05-22T19:14:09+00:00

Let me know if I have to make this more concise, if you don’t

  • 0

Let me know if I have to make this more concise, if you don’t have time, just answer the question above and skip the following words:

I just wanted you to fully understand the problem. THANKS A LOT in advance.

BACKGROUND: I am making search engine (this is only a small part of the code… so it may be sensitive to change… not your problem). The search engine has to ouput all the sentences meeting a certain criteria. So if the sentence includes the right terms, it will be placed under a sub heading which is under a larger heading(in caps). The caps heading is sorted by alphabetical. I want the sub headings sorted by frequency.

OBJECTIVE: I thought of sorting by frequency by joining all the corresponding matches to the subheading, and then which every sub heading element is largest goes first. HOW DO I DO THIS? (Ex. $array[0] and $array[1] need to be concatenated)

APOLOGY: I am new to Perl and this site, so I’m not sure if this format is too long… I am sure and sorry that my code is crude, but it works

HERE WE GO:

LEGEND1: $sortedallgramfunc is of the form: XCOMP

LEGEND2: $headmatches (the subheading) is of the form: xcomp of expend is: move

LEGEND3: $sentmatches is of the form: MATCH #1 Sent. 29
To acquire these organic molecules , animals must –expend– energy to move themselves

If the subheading has MATCH #2 as well, it and all the sentences associated, should be printed before a subheading with only 1 match

foreach my $sortedallgramfunc (@sortedallgramfunc) {
my @sepmatches; ## MOVED DOWN HERE TO TEST, MAYBE MOVE BACK depending on sol'n
print ("\n",uc $sortedallgramfunc,"\n\n");# Which gramfunc is being shown?

for (my $l=0; $l <= @headmatches; $l++) {
    if (defined( $headmatches[$l] ) and $headmatches[$l] =~ /$sortedallgramfunc/) {

        unless ($seenmatches{ $headmatches[$l] }++) {
            push (@sepmatches, $headmatches[$l]);
            my $count = 1;
            my @allsents; ## use for all sents that go under heading, add to heading to get @allmatches
            for (my $m=0; $m <= @sentmatches; $m++) {
                if ( defined( $sentmatches[$m]) and $sentmatches[$m] =~ /\s\S\S$firstmatches[$l]\S\S\s/ and $sentmatches[$m] =~ /\s\S\S$secondmatches[$l]\S\S\s/) { ##We know $l and $m are matching

                    push (@allsents, "MATCH #$count $sentmatches[$m]"); # unless $seens{ $sentmatches[$m] }++);
                    $count++;

                }
            }
            push (@sepmatches, @allsents);

            ##$sepmatches[0] is header, [1] is all sentences etc. EVEN - header, ODD - sent
            ## NOW WANT TO join headers and sentences (0 and 1 etc.) in @allmatches<====
             # SO I can us the following line to hopefully sort by frequency of matches under each subheading: @sortedallmatches = sort {length $a cmp length $b } @allmatches;

        }
    }
}print @sepmatches;
}
  • 1 1 Answer
  • 1 View
  • 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-22T19:14:10+00:00Added an answer on May 22, 2026 at 7:14 pm

    You likely want List::MoreUtil’s natatime. This is a duplicate of many other questions along the same lines, such as How do I read two items at a time in a Perl foreach loop?.

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

Sidebar

Related Questions

This is a long shot, I know... Let's say I have a collection List<MyClass>
This may be subjective, I don't know: I have this problem, which I'm kind
EDIT To make this post a bit more constructive, and let it possibly help
Please let me know if you have any idea about it. Thanks EDIT What
Please let me know how to get the client IP address, I have tried
I am new to testing.I have to test some C# classes.Kindly let me know
So let's say I have a matrix, mdat and I only know the index
Let me know if anyone know what is the issue with this code. Basically
I am on a tight schedule with my project so don't have time to
I am very sorry if my question doesn't make sense as this is my

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.