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
  • 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-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 more of a MVVM question than a caliburn question, but it relates
I don't think this is possible, but it never hurts to ask. Is there
I have some database functions and would like to make those database functions accessible
This is my first post in any forum so please bear with me. I
I have 3 tables: KeyWords, GrantsKeyConn, Grants. The way it is set up, each
I'm trying to show wall posts that all users have made on a specific
How do I make the form send keystrokes such as Tab, Enter, Left Arrow
Background I have a couple of projects that use a SQLite DB for data.
I am creating a application which displays 8 thumbnails per page and it can
I am working on a program which I want to draw diode curves in

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.