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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:21:58+00:00 2026-05-24T08:21:58+00:00

I am trying to do this boolean expression in perl and my code is

  • 0

I am trying to do this boolean expression in perl and my code is supposed to be like this

enter code here

 $flag = 0;
  while (<INFILE>)
{

if(/name/ && $flag==0)
 {
   $flag = 1;

 print "HELLO\n";
 }
elsif($flag)
{
  print "Bye\n";

My plan is to write something like this

flag=0
while<>
if(/name/ && !flag)
flag=1;
elsif(flag)
last;

So is there anything wrong in what i did in the code what i reproduced? Is this the way of declaring a true and false value in perl

  • 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-24T08:21:58+00:00Added an answer on May 24, 2026 at 8:21 am

    Based on your comment below:

    while (<>) {
        $flag = 1 if /name/;
        if ($flag) {
            # do something
        }
    }
    

    Or you can do:

    while (<>) { last if /name/ }
    while (<>) {
        # do something
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying this code: entLoop:for(var i:*in entities) { for(var i2:*in ignoreEntities) { if(entities[i].type==ignoreEntities[i2])
i get this error when trying this: ERROR method name expected. How should i
I'm trying to write a regular expression which should be able to identify boolean
I'm trying to set the Hidden-property of a Textbox based on this expression: =IIf(IsNothing(Parameters!customer_numbers.Value)
I'm trying to process a boolean expression that is stored as a string. They
I'm trying to generate a truth table for a given boolean expression. I could
This question is a result of what i noticed while trying to answer another
I am trying to pass a little-b boolean as an argument in this call:
I am trying to validate my string with the regular expression. Here is what
Possible Duplicate: Java string comparison? I was trying to do this: boolean exit =

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.