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

The Archive Base Latest Questions

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

Alright, I’m still a newbie in Perl, so the answer to this question may

  • 0

Alright, I’m still a newbie in Perl, so the answer to this question may seem fairly obvious, but I’ve done some work in Python, and I’ve encountered a problem with learning the if, elsif, and else loops; specifically, that they don’t work properly. Here’s my code:

my $x = 0;
print "X has been set to ". $x .".\n";

while ($x<11)
{
  $x++;
  print "The value of x is now ". $x .".\n";
  if ($x>4, $x<7){
      print "Something\n";
      system ("Pause");
  }

  elsif ($x>7, $x>11){ #<--Here
  print "Something else\n";
  system ("Pause");
  }

  elsif ($x==11){
      print "Last line\n";
  }
} #<-- and Here
system "Pause";

Maybe my problem is obvious by now, but if not, the problem is that it doesn’t seem to be evaluating any of the expressions; it just prints the first loop it finds anyway, which in this case is the if loop. If i remove it, or comment it out, it goes straight to the first elsif loop; that is, no matter the value of x, it prints the first loop it finds without any sort of evaluation. When I added

use strict;
use warnings;

I got the warning “Useless use of numeric gt (>) in void context at line 16” and the same thing for line 24. I marked those out in the original code with the arrows and here. Am I doing something/not doing something I should be?

  • 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-21T04:23:29+00:00Added an answer on May 21, 2026 at 4:23 am
    use strict;
    use warnings;
    
    while ($x<11)
    {
      $x++;
      print "The value of x is now ". $x .".\n";
      if ($x>4 and $x<7){
          print "Something\n";
          system ("Pause");
    
      }elsif ($x>7 and $x>11){ #<--Here
        print "Something else\n";
        system ("Pause");
    
      }elsif ($x==11){
          print "Last line\n";
      }
    } #<-- and Here
    system "Pause";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright. This may be difficult but I have been struggling for quite a bit
Alright, this is driving me nuts because my regex is working on Rubular, but
Alright so I have no idea how to even begin doing this But basically
Alright I created some custom classes for my project sourced from this tutorial ,
Alright here is the thing, I have this site that was once wordpress but
Alright, I've got what should be an easy question but there are literally no
Alright, I know I've asked similar questions, but I feel this is hopefully a
Alright, so I'm about 90% sure that this isn't possible, but I thought I'd
Alright, so this is an extension to a question I asked last night. I
Alright, I found out in this question that polling sockets does not scale, so

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.