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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:22:22+00:00 2026-05-23T13:22:22+00:00

This has been moved to a test case here . RE-DONE: I want to

  • 0

This has been moved to a test case here.

RE-DONE:

I want to return arrays (must be references) from 2 subroutines, however the regex used as a conditional statement isn’t working as I’d hoped. I’ve tried doing it with one, but I figure this will be easier.

To be clear, my goal is to have an array of matches sorted (@all_matches), and then add on another array (@all_pronoun_matches) sorted the same way but added at the end.

This is the @pronoun_matches subroutine:

my ($line, $verbform, $chapternumber, $sentencenumber, $sentence) = @_;
my @matches;
my @pronoun_matches;
return unless ($line =~ /(\w+)\((\w+)\-\d+\,\s(\w+)\-\d+\)/); #2nd repeat check     
$grammar_relation = $1;
$argument1 = $2;
$argument2 = $3;
    
return if (($argument1 =~ /^$argument2/i)||($argument2 =~ /^$argument1/i));    

foreach my $pronoun (@stopListNoun)
    {
    if ((lc $pronoun eq lc $argument1) || (lc $pronoun eq lc $argument2)) 
        {
        push (@pronoun_matches, $chapternumber, $sentencenumber, $sentence, $grammar_relation, $argument2, $argument1) if ($argument2 =~ /$verbform/i);
        push (@pronoun_matches, $chapternumber, $sentencenumber, $sentence, $grammar_relation, $argument1, $argument2) if ($argument1 =~ /$verbform/i);
        }
    else
        {return}
    }
    
return (\@pronoun_matches);

The @matches has a very similar subroutine except this:

foreach my $pronoun (@stopListNoun) #Just a list of words
    {
    return if ((lc $pronoun eq lc $argument1) || (lc $pronoun eq lc $argument2));
    }
    
    push (@matches, $chapternumber, $sentencenumber, $sentence, $grammar_relation, $argument2, $argument1) if ($argument2 =~ /$verbform/i); ##USED TO BE 'eq', but that prevented protective from showing
    push (@matches, $chapternumber, $sentencenumber, $sentence, $grammar_relation, $argument1, $argument2) if ($argument1 =~ /$verbform/i);
    
    return \@matches;

This is called by:

my $matches;
my $pronoun_matches;
$matches = &dependency_checks($lines[$l], $verbform, $chapternumber, $sentencenumber, $sentence);
$pronoun_matches = &pronoun_dependency_checks($lines[$l], $verbform, $chapternumber, $sentencenumber, $sentence);
push @all_matches, $matches if ($matches);
push @all_pronoun_matches, $pronoun_matches if ($pronoun_matches);

To send to the print section after being sorted using hashes, I’d like to use:

@all_matches = (@all_matches, @all_pronoun_matches); However, @all_pronoun_matches has 0 matches (or they are being filtered somewhere).

Question

Why does @all_pronoun_matches have uninitialized values in it??
After some testing, I’ve found that the match never gets passed the conditional statement, but it’s the same as the one in the @matches subroutine!


Originally, I had just wanted to remove the pronouns and it worked fine, so I know the condition works:

foreach my $pronoun (@stopListNoun)
        {
        return if ((lc $pronoun eq lc $argument1) || (lc $pronoun eq lc $argument2));
        }

I’ve tried using an if-else in the foreach and combining the subroutines, but then all the matches (including pronouns) went into @all_matches despite being called correctly (this method was posted here before).

Let me know if anything is unclear about my intent or the problem.

  • 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-23T13:22:23+00:00Added an answer on May 23, 2026 at 1:22 pm
    @all_matches = @matches, @all_pronoun_matches;
    

    should be

    @all_matches = ( @matches, @all_pronoun_matches );
    

    , has lower precedence than =

    If you had warnings enabled, you would have gotten a Useless use of a variable in void context warning alerting you that @all_pronoun_matches didn’t become part of the assignment.

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

Sidebar

Related Questions

This has been a problem that I haven't been able to figure out for
This has been an adventure. I started with the looping duplicate query located in
This has been driving me crazy for a few days. Why doesn't the following
This has been troubling me for a few years, and was recently exacerbated by
This has been asked before (question no. 308581) , but that particular question and
This has been confusing me for some time. With the advent of UTF-8 as
This has been a rather problematic issue on numerous occasions. We have alot of
This has been driving me crazy for the past few minutes I have a
This has been one of the biggest obstacles in teaching new people ColdFusion. When
This has been driving me nuts. I keep getting the following exception System.InvalidOperationException: The

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.