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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:12:57+00:00 2026-05-25T03:12:57+00:00

I am basically a networking guy and so not good at writing scripts. While

  • 0

I am basically a networking guy and so not good at writing scripts.

While writing some scripts I came across below requirement.

I have a hash array with some values of "1" or "2" and my requirement

if all of the value equal to other than "1" (could be "2" or "3") then it will print some statement once and then come out of that loop.

if any of the value equal to "1" then it will print some statement.

ex:

my %hash_array1=(A=>2,B=>2,C=>2);
my @array2=values (%hash_array1);

foreach my $line (@array2) {

    if ($line!=1) {

        print BOLD GREEN "\rNo Evolution ",RESET;

        last;
    }
    else {
        print BOLD RED "Evolution \n",RESET;
    }
}

which print

No Evolution

Above code work well as expected for mentioned hash_array because all values are non-"1",but not working well for below hashes

my %hash_array1=(A=>1,B=>2,C=>2);

where it prints

Evolution

No Evolution

which is not as per my expectation. I want here to print as one time "Evolution" and "No Evolution" should not be printed any more. (However loop should be continued to iterate)

Please let me know if more clarity is required.

Regards

Mahesh

  • 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-25T03:12:59+00:00Added an answer on May 25, 2026 at 3:12 am

    I would use something like:

    #!/usr/bin/perl
    my %hash_array1=(A=>1,B=>1,C=>2);
    my $values = join('', values(%hash_array1));
    
    if ($values =~ /1/) {
        print "at least one 1";
    } else {
        print "no 1";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not too familiar with networking in JAVA but what i'm basically trying to
Basically I have some code to check a specific directory to see if an
I'm just testing out some basic networking code written in Visual C++. I have
I'm a good programmer, but I have zero network experience. Basically, I'd like to
I have an application that tries to be a good samaritan, basically, when any
I'm writing some pexpect stuff that's basically sending commands over telnet. But, it's possible
Okay I'm having a problem. I have a social networking site and have some
I am new to networking. I just basically want to know whether we can
Hi i have a social networking website. what i want it to do is
Basically I have an asp.net website with login and search pages. Currently, I have

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.